Context Eligibility API

The Context Eligibility API identifies context combinations of products and promotions that are eligible for each of the combinations. The API accepts cacheKey as the request body parameter for Context Eligibility. Context Eligibility is an output parameter consisting of generated context combinations.

For each context combination in the output of the Context Combinations API, there is one context eligibility in the API response that contains qualifying products and promotions for that context combination.

You can obtain the cacheKey required in the request body of this API from the cacheKey node in the response body of the Context Combinations API.

Precondition 

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

URI 

/services/apexrest/{namespace}/v3/admin/catalogs/{catalogCode}/contexteligibility

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/contexteligibility?effectiveStartTime=2021-07-04T12:08:56&expirationTime=2021-08-04T12:08:56

Request Body Parameters 

ParameterData TypeDescriptionDefaultOptional/Required
cacheKeyStringCache key pointing to the record containing combinations for the context eligibility that needs populating. You can obtain the cacheKey required in the request body of this API from the cacheKey node in the response body of the Context Combinations API.N/ARequired

Sample Request Body 

This is a sample request for a cacheKey.

1{
2    "cacheKey": "1f1d5f350cb0efd232086e274ef00647"
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 = 'getEligibility';
9requestBodyJSON = '{"cacheKey":"1f1d5f350cb0efd232086e274ef00647"}';
10input.put('apiName','CMContextEligibility'); //required
11input.put('catalogCode', 'TestCatalog');     //required
12input.put('effectiveStartTime', null);       //optional
13input.put('expirationTime', null);           //optional
14input.put('requestBody', requestBodyJSON);   //required
15input.put('methodName',methodName);          //required
16input.put('requestURL', '/v3/admin/catalogs/TestCatalog/contexteligibility'); //required
17
18//remote action invocation
19vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
20appHandler.invokeMethod(methodName, input, output, options);

Parallel Invocation 

You can process each contextCombinationResultItem in parallel. If there are 100 catalogs and each catalog links to 13 contextCombinationsResultItems, then all 1,300 contextCombinationResultItems can be run in parallel.

1THREAD1 -  POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/contexteligibility
2THREAD2 -  POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/contexteligibility
3...
4THREAD13 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog1/contexteligibility
5THREAD14 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog2/contexteligibility
6......
7THREAD1300 - POST /services/apexrest/{namespace}/v3/admin/catalogs/catalog100/contexteligibility

HTTP Headers 

HeaderDescription
Content-Typeapplication/json

Response Body 

This example shows the context combinations of products and promotions that are eligible for each of the combinations.

1{
2    "apiResponse": [
3        {
4            "eligibilityObjMap": {
5                "Promotion": [],
6                "Product": [
7                    "01t5w00000FbI08AAF"
8                ]
9            },
10            "contextValueKeySet": [
11                "DIM_ORD_FUNCTION\"UPGRADE\"",
12                "DIM_SALES_CHANNEL\"VHAOnlineStore\"",
13                "DIM_ORD_TYPE_001\"Connect\"",
14                "OriginatingChannel\"CallCenter\"",
15                "AccountStatus\"Active\""
16            ],
17            "contextValueKeyCount": 5,
18            "eligibilityContextString": "testcatalogCtxEligibilityResult0a49c26b44fcf8257224e7e077a5d97c",
19            "eligibilityContextKey": "c161669788f961dba463ed0742f17622",
20            "contextString": "{\"AccountStatus\":\"Active\",\"DIM_ORD_FUNCTION\":\"UPGRADE\",\"DIM_ORD_TYPE_001\":\"Connect\",\"DIM_SALES_CHANNEL\":\"VHAOnlineStore\",\"OriginatingChannel\":\"CallCenter\"}",
21            "contextKey": "0a49c26b44fcf8257224e7e077a5d97c"
22        }
23    ],
24    "catalogCode": "allDimensionProductsCatalog-",
25    "errorCode": "INVOKE-200",
26    "error": "OK"
27}

HTTP Response Codes 

CodeDescription
200OK
500Internal Server Error