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

Use the example SDK code in this topic to obtain 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
8input.secureApiCall = false; // set to true if needs secure api calls without context parameters and session key.
9
10// Invoke GetContainsProducts API via method getOffers()
11digitalCommerce
12 .getOffers(input)
13 .then(result => {
14   Logger.info("vlocity get offers anonymous user rest call" + result);
15 })
16 .catch(error => {
17   Logger.info("get offers anonymous user rest call failed" + error);
18 });

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