SDK Example: getOfferDetails via API (Fall ‘19)

Use the example SDK code in this topic to validate an offer.

1// Instantiate the input object for getOfferDetails to specify parameters
2const input = digitalCommerce.createGetOfferInput();
3input.catalogCode = "Phones"; // use your Catalog Code
4input.offerCode = "iPhoneXS"; // use your Offer Code
5input.cacheable = false; // Optional Flag to indicate if the sdk call should be cached. Default is false.
6input.reload = false; // Optional Boolean flag to discard cache and call the api again. Default is false.
7input.isLoggedIn = true; // use to fetch offers based on given accountId - optional
8input.context = '{"accountId":"ACCOUNT ID"}'; // use to fetch offers based on given context params - optional
9input.customFields = ["customAttribute__c"]; // optional field which returns your custom attributes or any given keys
10
11// Invoke GetOfferDetails API via method getOfferDetails()
12digitalCommerce
13  .getOffer(input)
14  .then(response => {
15    Logger.info("vlocity get offer anonymous user rest call" + response);
16  })
17  .catch(error => {
18    Logger.info("get offer anonymous user rest call failed" + error);
19  });

Possible error conditions:

“GetOfferInput::getAPIPath() must have catalogCode.”

“GetOfferInput::getAPIPath() must have offerCode.”