SDK Example: getOfferDetails via API (Fall '20)

Use the example SDK code in this topic to obtain offer details via the API.

// Instantiate the input object for getOfferDetails to specify parameters
const input = digitalCommerce.createGetOfferInput();
input.catalogCode = "Phones"; // use your Catalog Code
input.offerCode = "iPhoneXS"; // use your Offer Code
input.cacheable = false; // Optional Flag to indicate if the sdk call should be cached. Default is false.
input.reload = false; // Optional Boolean flag to discard cache and call the api again. Default is false.
input.isLoggedIn = true; // use to fetch offers based on given accountId - optional
input.context = '{"accountId":"ACCOUNT ID"}'; // use to fetch offers based on given context params - optional
input.customFields = ["customAttribute__c"]; // optional field which returns your custom attributes or any given keys

// Invoke GetOfferDetails API via method getOfferDetails()
digitalCommerce
  .getOffer(input)
  .then(response => {
    Logger.info("vlocity get offer anonymous user rest call" + response);
  })
  .catch(error => {
    Logger.info("get offer anonymous user rest call failed" + error);
  });

Possible error conditions:

  • "GetOfferInput::getAPIPath() must have catalogCode."

  • "GetOfferInput::getAPIPath() must have offerCode."