@nuskin/configuration-sdk
"The configuration sdk gets market configuration from content stack. You can get the full configuration for a list of config maps or get partial configuration using graphql. The sdk caches the configurations for 2 minutes in memory. The sdk also allows for configuraitons to be overridden. Override configurations for runtime shopping context configurations. Or use the function for testing purposes to override configuration in the browser on the fly.",
Installing
Usng npm:
npm add @nuskin/configuration-sdk
Usng yarn:
yarn add @nuskin/configuration-sdk
Example usage
const {init, overrideConfigurationProperty, clearConfigurationOverrides, overrideConfiguration, getConfiguration, getPartialConfig} = require('@nuskin/configuration-sdk');
init(AsyncStorage.set, AsyncStorage.get);
overrideConfigurationProperty({configMap: 'Ordering', configMapProperty: 'testing', value: true, country: 'US', shoppingContext: 'personal_offer'});
overrideConfiguration({configMap: ''});
window.nuskin.overrideConfiguration = overrideConfiguration;
const config = await getPartialConfig({
queryFields: {
Ordering: ['spendingRestrictionsEnabled', 'inventoryCheckEnabled'],
Cart: ['minAdrPsv']
},
country: 'US',
clientId: 'Client id for you application'
});
const config = await getConfiguration({
configMapNames: ['Ordering', 'Cart'],
country: 'US',
clientId: 'Your application client id'
});
Resources
License
MIT