getRewardsSpendingRules
Retrieves the list of spending rules items. The locale parameter is optional and can be used to customize the response based on the desired language.
sdk.rewards.methods.getRewardsSpendingRules()getRewardsSpendingRules(locale: string): Promise<ErrorResult | SuccessResult<SpendingRulesSdkResultDTO[]>>Parameters
localestring
Returns
Promise<ErrorResult | SuccessResult<SpendingRulesSdkResultDTO[]>>Usage example
Before call a request, ensure the SDK and the Rewards module are ready:
function onSdkReady() {
const moduleName = window.gw.sdk.common.constants.modules.REWARDS;
window.gw.sdk.runIfModuleReady(moduleName, () => {
window.gw.sdk.rewards.methods
.getRewardsSpendingRules()
.then(console.log)
.catch(console.error);
});
}
if (window.gw && window.gw.sdk) {
onSdkReady();
} else {
document.addEventListener("gwSdkReady", onSdkReady);
}
This code ensures that the SDK and the Rewards module are ready before attempting to call a request. The method will either succeed, returning a success result, or fail, returning an error with details about what went wrong.