1/*
2 * We can override this default implementation by defining the following interface
3 * INTERFACE : DCAPIParamsInterface
4 */
5global class DCAPIParamsImplementation implements vlocity_cmt.VlocityOpenInterface {
6 public static Map < String, String > overiddenParamMap = new Map < String, String > {};
7 static {
8 //Field should have their own string here for getoffers api
9 overiddenParamMap.put('GetOffers', '{"batchSize":20,"productFields" : ["vlocity_cmt__IsActive__c"]}');
10 //Field should have their own string here for getofferdetails api
11 overiddenParamMap.put('GetOfferDetails', '{"batchSize":20}');
12 //Field should have their own string here for getrelatedofferdetails api
13 overiddenParamMap.put('GetRelatedOffers', '{"batchSize":20, "productFields" : ["vlocity_cmt__IsActive__c"]}');
14 }
15 global DCAPIParamsImplementation() {}
16
17 global static Boolean invokeMethod(String methodName, Map < String, Object > inputs, Map < String, Object > outputs, Map < String, Object > options) {
18 if (methodName == 'fetchAPIParamsOverride') {
19 return fetchAPIParamsOverride(inputs, outputs, options);
20 }
21 return false;
22 }
23
24 /*
25 Inputs :
26 1) key : apiName, type : String
27 2) key : params, type : String
28 Outputs :
29 1) key : result, type : String
30 */
31 public static Boolean fetchAPIParamsOverride(Map < String, Object > inputs, Map < String, Object > outputs, Map < String, Object > options) {
32 String apiName = (String) inputs.get('apiName');
33 String overiddenParam = overiddenParamMap.get(apiName) == null ? ((String) inputs.get('params')) : overiddenParamMap.get(apiName);
34 outputs.put('result', overiddenParam);
35 return true;
36 }
37}