Digital Commerce Remote Calls

You can use the code samples in this topic to make remote method calls to the Digital Commerce APIs for both anonymous and logged-in users.

Sample Remote Calls 

Get Offers By Catalog for Anonymous Users:

1String methodName;
2
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 = 'getOffersByCatalogCode';
9input.put('apiName','getOffers');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('pagesize','20');
12input.put('offset','0');
13
14//remote action invocation
15vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
16appHandler.invokeMethod(methodName, input, output, options);

For more details about which parameters correspond to the POST body, refer to the API documentation.

Get Offers By Catalog for Logged In Users:

1String methodName;
2
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 = 'getOffersByCatalogCode';
9input.put('apiName','getOffers');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('pagesize','20');
12input.put('offset','0');
13input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
14input.put('isloggedin','true');
15
16//remote action invocation
17vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
18appHandler.invokeMethod(methodName, input, output, options);

Get Contains Products for Anonymous Users:

1String methodName;
2
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 = 'getOffersByCatalogCode';
9input.put('apiName','GetContainOffers');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/offers?contains=Child1&context={}&pagesize=20&offset=0');
12input.put('productCode', 'Child1');input.put('pagesize','20');
13input.put('offset','0');
14
15//remote action invocation
16vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
17appHandler.invokeMethod(methodName, input, output, options);

Get Contains Products for Logged In Users:

1String methodName;
2
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 = 'getOffersByCatalogCode';
9input.put('apiName','GetContainOffers');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/offers?contains=Child1&pagesize=20&offset=0');
12input.put('productCode', 'Child1');input.put('pagesize','20');
13input.put('offset','0');
14input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
15input.put('isloggedin','true');
16
17//remote action invocation
18vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
19appHandler.invokeMethod(methodName, input, output, options);

GetOfferDetailsByCatalog for Anonymous Users:

1String methodName;
2
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 parametersmethodName = 'getOfferDetailsByCatalogCode';
8input.put('apiName','getOfferDetails');
9input.put('catalogCode', 'ECOMM-CAT1');
10input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/offers/iPhone8Bundle');
11
12//remote action invocation
13vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
14appHandler.invokeMethod(methodName, input, output, options);

GetOfferDetails ByCatalog for Logged In Users:

1String methodName;
2
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 = 'getOfferDetailsByCatalogCode';
9input.put('apiName','getOfferDetails');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/offers/iPhone8Bundle');
12input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
13input.put('isloggedin','true');
14
15//remote action invocation
16vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
17appHandler.invokeMethod(methodName, input, output, options);

Get Basket for Logged In Users:

1String methodName;
2
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 = 'getBasket';
9input.put('apiName','basketOperations');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
12input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
13input.put('isloggedin','true');
14input.put('cartContextKey', 'cartContextKey');
15
16//remote action invocation
17vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
18appHandler.invokeMethod(methodName, input, output, options);

POST API Sample Calls 

Configure Offer for Anonymous or Logged In Users:

1String methodName;
2
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 = 'configureOfferDetail';
9input.put('apiName','ConfigureOfferDetail');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('offerCode', 'iPhone8Bundle');
12input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/offer/iPhone8Bundle');
13input.put('result', '{{offerdetailsStructure}}');
14
15//remote action invocation
16vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
17appHandler.invokeMethod(methodName, input, output, options);

Additional parameters:

1// Transactional break for ValidateAndPriceAction 
2input.put('orderId', '{{transactionKey}}');
3
4// validate and price 
5input.put('validate', false);
6input.put('price', false);

Basket API for Anonymous or Logged In Users:

1String methodName;
2
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 parametersmethodName = 'addWithNoConfig';
8input.put('apiName','basketOperations');
9input.put('catalogCode', 'ECOMM-CAT1');
10input.put('offer', 'Product1');input.put('methodName', 'addWithNoConfig');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
12
13//remote action invocation
14vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
15appHandler.invokeMethod(methodName, input, output, options);

Additional parameters include different method names (note that their first letter is not capitalized unlike in REST POST body params):

  • addWithNoConfig

  • addAfterConfig

  • deleteFromBasket

Additional input map parameters include:

  • offerDetails - same as productConfig

  • orderId - same as transactionKey

  • cartContextKey

  • deleteBundleNumber

Refer to Basket APIs documentation for more details on what they correspond to in POST body params.

1// validate and price 
2input.put('validate', false);
3input.put('price', false);

Basket API: Asset to Basket for Logged In Users:

1String methodName;
2
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 = 'assetToBasket';
9input.put('apiName','basketOperations');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
12input.put('methodName', 'assetToBasket');
13input.put('context','{"accountId":"accountId1", "contractId":"contractId1", "rootAssetIds":["rootItemId1", "rootItemId2"]}');
14input.put('isloggedin','true');
15input.put('rootAssetIds', 'rootItemId1,rootItemId2');
16input.put('requestDateTime', '2020-01-08T12:00:00.000z');
17input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
18
19//remote action invocation
20vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
21appHandler.invokeMethod(methodName, input, output, options);

Additional Parameters:

1// validate and price 
2input.put('validate', false);
3input.put('price', false);

Basket API: Delete From Basket for Anonymous or Logged in Users:

1String methodName;
2
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 = 'deleteFromBasket';
9input.put('apiName','basketOperations');
10input.put('methodName','deleteFromBasket');
11input.put('catalogCode', 'ECOMM-CAT1');
12input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
13input.put('cartContextKey', 'cartContextKey');
14
15//Use the cart context
16keyinput.put('bundleContextKey', 'bundleContextKey');
17
18//Use the key of the bundle under which the line to be deleted
19input.put('lineItemKey', 'lineItemKey');
20
21//Use the key of the line to be deleted
22input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
23input.put('isloggedin','true');
24
25//remote action invocation
26vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
27appHandler.invokeMethod(methodName, input, output, options);

Additional parameters:

1// validate and price 
2input.put('validate', false);
3input.put('price', false);

Basket API: Update Basket for Anonymous or Logged In Users:

1String methodName;
2
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 = 'updateBasket';input.put('apiName','basketOperations');
9input.put('methodName','updateBasket');
10input.put('catalogCode', 'ECOMM-CAT1');
11input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
12input.put('cartContextKey', 'cartContextKey');
13
14//Use the cart context keyinput.put('bundleContextKey', 'bundleContextKey');
15
16//Use the key of the bundle under which the line to be deleted
17input.put('lineItemKey', 'lineItemKey');
18
19//Use the key of the line to be updatedinput.put('Quantity', 5);
20
21//Quantity to be updated
22input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
23input.put('isloggedin','true');
24
25//remote action invocation
26vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
27appHandler.invokeMethod(methodName, input, output, options);

Additional parameters:

1// validate and price
2input.put('validate', false);
3input.put('price', false);
4
5// to update attribute 
6input.put('attributeCategories', 'attributecategorystring'); //attribute category to be updated

Basket API : Add Multiple Items to a Basket:

1String methodName;
2Map<String, Object> input = new Map<String, Object>();
3Map<String, Object> output = new Map<String, Object>();
4Map<String, Object> options = new Map<String, Object>();
5
6methodName = 'addWithNoConfig';
7input.put('apiName','basketOperations');
8input.put('catalogCode', 'ECOMM-CAT1');
9input.put('productConfig', [list of product configs]); //this is the list of product configs or single product config to add
10input.put('offer', [list of offers to add]); //list of offer codes to add or single offer code to add
11input.put('methodName', 'addAfterConfig');
12input.put('requestURL', '/v3/catalogs/ECOMM-CAT1/basket');
13
14//remote action invocation
15vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
16appHandler.invokeMethod(methodName, input, output, options);

Create Cart for Logged In Users:

1String methodName;
2
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 = 'createEcomCart';
9input.put('apiName','createEcomCart');
10input.put('methodName','createEcomCart');
11input.put('catalogCode', 'ECOMM-CAT1');
12input.put('requestURL', '/v3/carts');
13input.put('cartContextKey', 'cartContextKey');//Use the cart context key
14input.put('context','{"accountId":"accountId1", "contractId":"contractId1"}');
15input.put('isloggedin','true');
16
17//remote action invocation
18vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
19appHandler.invokeMethod(methodName, input, output, options);

Additional Parameters

1// validate and price
2input.put('validate', false);
3input.put('price', false);
4
5//Old format:
6 input.put('catalogCode', 'Mobiles');
7input.put('accountId', '001f200001eSlhe');
8input.put('JSONResult', '{{AddTobasketResponse}}');

Basket API : Add Child Items to a Basket:

1String methodName;
2
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 = 'addWithNoConfig';
9input.put('apiName','basketOperations');
10input.put('catalogCode', 'catalog_Apr18');
11input.put('offer', '300MbpsRouter-129356540');
12input.put('methodName', 'addWithNoConfig');
13input.put('cartContextKey', '1aa8bcbb632946e295cbe98b2fffa91b');
14input.put('parentHierarchyPath', '01tDH000000MYRPYA4');
15input.put('bundleContextKey', 'a9347c07-9793-4e78-8371-9ac4e50e96df');
16input.put('parentLineItemKey', 'a9347c07-9793-4e78-8371-9ac4e50e96df');
17input.put('requestURL', '/v3/catalogs/catalog_Apr18/basket');
18
19//remote action invocation
20vlocity_cmt.CpqAppHandler appHandler = new vlocity_cmt.CpqAppHandler();
21appHandler.invokeMethod(methodName, input, output, options);