SDK Example: Get List of Promotions or Promotions associated with a Product (Fall ‘20)

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

1// Instantiate the input object for getOffers to specify parameters.
2const input = digitalCommerce.createGetOffersInput();
3input.catalogCode = "Phones"; // use your Catalog Code
4input.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
5
6// Invoke GetOffersByCatalog API via method getPromotions()
7digitalCommerce
8  .getPromotions(input)
9  .then(result => {
10    Logger.info("vlocity get promotions anonymous user rest call" + result);
11  })
12  .catch(error => {
13    Logger.info("get promotions anonymous user rest call failed" + error);
14  });

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.”