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

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

1// Instantiate the input object for getOffers 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.contains = "iPhone8"; // find all offers that CONTAIN "iPhone8" - optional
7input.customFields = ["customAttribute__c"]; // optional field which returns custom fields for given keys
8
9// Invoke GetContainsProducts API via method getOffers()
10digitalCommerce
11 .getOffers(input)
12 .then(result => {
13   Logger.info("vlocity get offers anonymous user rest call" + result);
14 })
15 .catch(error => {
16   Logger.info("get offers anonymous user rest call failed" + error);
17 });

Possible error conditions:

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

“GetOffersContainsInput::getAPIPath() should not have both sortBy and contains.”

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

“GetOffersContainsInput::getAnonymousRestUrl() should not have both sortBy and contains.”