Contains Offer API

Running the Contains Offer API is optional.

The Contains Offer API finds all the products and promotions that contain a given offer in their hierarchy and also qualifies under the given context combination. This API also paginates and sorts the list of products and promotions and caches the result. This API adds the required action nodes to the responses if there are remaining pages after the current page.

You can obtain the ctxEligibilityCacheKey required in the request body of this API from the apiResponse.eligibilityContextKey node in the response body of the Context Eligibility API.

You can obtain the offerId required in the URI of this API from the apiResponse.data.catalogProductRelationDetails.Product node in the response body of the Catalog Profile API.

Preconditions 

You must first run the Context Eligibility API to obtain the offerId required in the request body of this API.

URI 

/services/apexrest/{namespace}/v3/admin/catalogs/{catalogCode}/offers/{offerId}/containsoffer

HTTP Method 

POST

URI Parameters 

If you specify just one of these two parameters, it follows the behavior described in the table below and accepts your defined time for the parameter you specified. If you are using one or both parameters, you must specify them with the same values for all of the Populate Cache APIs in this sequence.

ParameterExampleDefaultOptional/RequiredNotes
effectiveStartTime2001-07-04T12:08:56Current date and timeOptionaleffectiveStartTime is the time that you want your cached catalog entries to be effective. It should be in the UTC date-time format. Your effectiveStartTime must occur after the current time for which you are executing the Populate Cache APIs or you will receive an error message.
expirationTime2001-07-04T12:08:56effectiveStartTime + TimeToLiveOptionalexpirationTime is the time that you want your cached catalog entries to expire. It should also be in the UTC date-time format. Your expirationTime must occur after your effectiveStartTime or you receive an error message. TimeToLive is a custom setting created in CPQ Configuration Setup. It has a default value of 30 days.

Here is an example of how to pass the URI parameters:

1GET /services/apexrest/vlocity_cmt/v3/admin/catalogs/AS-Test-Catalog/containsoffer?effectiveStartTime=2021-07-04T12:08:56&expirationTime=2021-08-04T12:08:56

Request Body Parameters 

ParameterData typeDescriptionDefaultOptional/Required
ctxEligibilityCacheKeyStringCache key pointing to the context eligibility record whose context combination calculates the eligibility of offers returned by this API.Null, which produces a response for the default context combinationOptional

Sample Request Body 

This is a sample request for the ctxEligibilityCacheKey.

1{
2    "ctxEligibilityCacheKey": "200b3622d38bb67369192ced32fbda5c"
3}

Remote API 

This is an example of how you invoke the API using Apex:

1String methodName;
2String requestBodyJSON;
3Map<String, Object> input = new Map<String, Object>();
4Map<String, Object> output = new Map<String, Object>();
5Map<String, Object> options = new Map<String, Object>();
6
7// Setting remote parameters
8methodName = 'getContainingOffers';
9requestBodyJSON = '{"ctxEligibilityCacheKey":"02ab891802e4df7a0f68a0f998a55879"}';
10input.put('apiName', 'CMContainsOffer');    // required
11input.put('methodName', methodName);        // required
12input.put('catalogCode', 'TestCatalog');    // required
13input.put('offerId', '01t4x000000x269AAA'); // required
14input.put('requestBody', requestBodyJSON);  // required
15input.put('effectiveStartTime', null);      // optional
16input.put('expirationTime', null);          // optional
17
18//remote action invocation
19vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
20appHandler.invokeMethod(methodName, input, output, options);

Parallel Invocation 

You can run this API in parallel for multiple catalogs, offers, and context combinations. For example, there may be 100 products (Product1, Product2 … Product100) and 100 context combinations (Combo1, Combo2 … Combo100) that you can run in parallel.

1THREAD1 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product1/containsoffer
2THREAD2 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product1/containsoffer
3......
4THREAD100 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product1/containsoffer
5THREAD101 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product2/containsoffer
6......
7THREAD10000 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/offers/Product100/containsoffer

HTTP Headers 

HeaderDescription
Content-Typeapplication/json

Response Body 

This example shows products and promotions that contain a given offer in their hierarchy and also qualifies under the given context combination.

1[
2  {
3    "contextKey": "d187cb8118349e3e32460393c62e44e1",
4    "result": {
5      "Promotion": [
6        "a3T4x000000l39BEAQ"
7      ],
8      "Product": [
9        "01t4x000000wx2vAAA",
10        "01t4x000000wx2wAAA"
11      ]
12    }
13  }
14]

HTTP Response Codes 

CodeDescription
200OK
500Internal Server Error