SDK Example: Get List of Promotions or Promotions associated with a Product (Winter '20)

Use the example SDK code in this topic to retrieve all promotions or promotions that are associated with a product.

// Instantiate the input object for getOffers to specify parameters.
const input = digitalCommerce.createGetOffersInput();
input.catalogCode = "Phones"; // use your Catalog Code
input.offerCode = "iPhoneX"; //  If offerCode value is passed return all associated promotions for that product.If offerCode not passed return all promotions associated to products. - optional

// Invoke GetOffersByCatalog API via method getPromotions()
digitalCommerce
  .getPromotions(input)
  .then(result => {
    Logger.info("vlocity get promotions anonymous user rest call" + result);
  })
  .catch(error => {
    Logger.info("get promotions anonymous user rest call failed" + error);
  });

Possible error conditions:

"GetCatalogOffersInput::getAPIPath() must have catalogCode."

"GetCatalogOffersInput::getAnonymousRestUrl() must have anonymousSiteUrl."

"GetCatalogOffersContainsInput::getAPIPath() should not have both sortBy and contains.

"GetCatalogOffersContainsInput::getAnonymousRestUrl() should not have both sortBy and contains."