UNPKG

react-native-gigya-sdk

Version:
46 lines (42 loc) 1.73 kB
import getState from './getState'; import sendApiCall from './sendApiCall'; export default function (consentIds, options) { return new Promise(async (resolve, reject) => { try { var _state$regToken; if (consentIds.length < 1) { return reject(new Error('No consent schema provided')); } const state = await getState(); const preferences = {}; consentIds.forEach(id => { const [consentTypeOrId, subConsentId] = id.split('.'); if (consentTypeOrId && subConsentId) { var _preferences$consentT; preferences[consentTypeOrId] = { ...((_preferences$consentT = preferences[consentTypeOrId]) !== null && _preferences$consentT !== void 0 ? _preferences$consentT : {}), [subConsentId]: { isConsentGranted: false } }; } else if (consentTypeOrId && !subConsentId) { preferences[consentTypeOrId] = { isConsentGranted: false }; } }); const response = await sendApiCall('accounts.setAccountInfo', { ...((options === null || options === void 0 ? void 0 : options.noUID) && { regToken: (options === null || options === void 0 ? void 0 : options.regToken) || ((_state$regToken = state.regToken) === null || _state$regToken === void 0 ? void 0 : _state$regToken.value) }), ...(!(options !== null && options !== void 0 && options.noUID) && { UID: (options === null || options === void 0 ? void 0 : options.UID) || state.UID }), lang: state.lang, preferences }); resolve(response); } catch (e) { reject(e); } }); } //# sourceMappingURL=declineConsentSchemas.js.map