react-native-gigya-sdk
Version:
SAP CDC/Gigya SDK for your React Native applications
26 lines (23 loc) • 1.37 kB
JavaScript
import sendApiCall from './sendApiCall';
export default function () {
return new Promise(async (resolve, reject) => {
try {
var _currentSiteConsents$;
const completeGigyaSchema = await sendApiCall('accounts.getSchema');
const currentSiteConsents = await sendApiCall('accounts.getConsentsStatements');
let output = [];
Object.entries((_currentSiteConsents$ = currentSiteConsents === null || currentSiteConsents === void 0 ? void 0 : currentSiteConsents.preferences) !== null && _currentSiteConsents$ !== void 0 ? _currentSiteConsents$ : {}).forEach(entry => {
var _completeGigyaSchema$, _entry$, _entry$2;
const consentStatementSchema = completeGigyaSchema === null || completeGigyaSchema === void 0 ? void 0 : (_completeGigyaSchema$ = completeGigyaSchema.preferencesSchema) === null || _completeGigyaSchema$ === void 0 ? void 0 : _completeGigyaSchema$.fields[entry[0]];
if ((_entry$ = entry[1]) !== null && _entry$ !== void 0 && _entry$.isActive && !((_entry$2 = entry[1]) !== null && _entry$2 !== void 0 && _entry$2.isMandatory) && consentStatementSchema) {
consentStatementSchema.key = entry[0];
output = [...output, consentStatementSchema];
}
});
resolve(output);
} catch (e) {
reject(e);
}
});
}
//# sourceMappingURL=getOptionalConsentSchemas.js.map