SDK Example: getCatalogOffers without the contains parameter (Fall ‘19)

Use the example SDK code in this topic to get catalog offers without the contains parameter.

1// Instantiate the input object for getCatalogOffers to specify parameters
2const input = digitalCommerce.createGetOffersInput();
3input.catalogCode = "Phones"; // use your Catalog Code
4input.offset = 0; // use for pagination - optional
5input.pageSize = 5; // use for pagination - optional
6input.isLoggedIn = true; // use to fetch offers based on given accountId - optional
7input.context = '{"accountId":"ACCOUNT ID", "contractId":"CONTRACT ID"}'; // use to fetch offers based on context params - optional
8input.includeAttributes = ["ishidden__c", "customAttribute__c"]; //includeExtraOfferAttributes as part of the query string of the API which includes extra passed attributes with default attributes in Offer - optional
9input.customFields = ["customAttribute__c"]; // optional field which returns custom fields for given keys
10
11// Invoke GetOffersByCatalog API via method getCatalogOffers()
12digitalCommerce
13  .getOffers(input)
14  .then(result => {
15    Logger.info("vlocity get offers anonymous user rest call" + result);
16  })
17  .catch(error => {
18    Logger.info("get offers anonymous user rest call failed" + error);
19  });

Possible error conditions:

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

“GetOffersInput::getAnonymousRestUrl() must have catalogCode.”