1String salesOrg = '0001';
2cgcloud.GetProductsCallout request = new cgcloud.GetProductsCallout(salesOrg);
3cgcloud.ProductResolutionConfiguration configuration = new cgcloud.ProductResolutionConfiguration(cgcloud.ProductResolution.ResponseFormat.DENORMALIZED /* || ProductResolution.ResponseFormat.NORMALIZED => Deprecated */);
4// Depending on each step we add, we will need to add some required properties to ProductResolutionConfiguration
5configuration.setSteps(new List<cgcloud.ProductResolution.ProcessStep>{
6 // Product Source: Execute a product query with the given product filter criteria.
7 // Requires 'productfilter', 'salesorg'
8 cgcloud.ProductResolution.ProcessStep.PRODUCTQUERY,
9 //Product Source: Extract manual fixed products from the input and adds them to the result.
10 // Requires 'manualproducts'
11 cgcloud.ProductResolution.ProcessStep.MANUALPRODUCTS,
12 //Product Source: Load products for the tactic actuals defined for the tactics of the promotion defined by PromotionId.
13 // Requires 'promotionid'
14 cgcloud.ProductResolution.ProcessStep.TACTICACTUALPRODUCTS,
15 //Product Source: Load products for the payment measures defined for the tactics of the promotion defined by PromotionId.
16 // Requires 'promotionid'
17 cgcloud.ProductResolution.ProcessStep.PAYMENTPRODUCTS,
18 //Product Source: Load products for the Promotion Conditions of the promotion defined by PromotionId.
19 // Requires 'promotionid'
20 cgcloud.ProductResolution.ProcessStep.PROMOTIONCONDITIONPRODUCTS,
21 //Product Source: Load frozen products of the promotion defined by PromotionId.
22 // Requires 'promotionid'
23 cgcloud.ProductResolution.ProcessStep.FROZENPRODUCTS,
24 //Product Filter: Products those are exclude manually will be filtered out from the dynamic product resolution result.
25 // Requires 'manualproducts'
26 cgcloud.ProductResolution.ProcessStep.MANUALEXCLUDEDPRODUCTSFILTER,
27 //Product Filter: Only planning products are returned from the dynamic product resolution result.
28 // Requires 'datefrom', 'datethru', 'referencedate' (KAMStateFilter by timeframe),
29 // or 'commitdate', 'referencedate' (KAMStateFilter by commit date)
30 cgcloud.ProductResolution.ProcessStep.KAMSTATEFILTER,
31 //Product Filter: Only products that are within the global account product list of the current account are returned from the dynamic product resolution result.
32 // Requires 'accountid'
33 cgcloud.ProductResolution.ProcessStep.GLOBALACCOUNTPRODUCTLISTFILTER,
34 //Product Filter: Only products that are part of the Authorization List of the Account defined by AccountId are returned from the dynamic product resolution result. Requires 'accountid', 'datefrom', 'datethru'
35 cgcloud.ProductResolution.ProcessStep.AUTHORIZATIONLISTFILTER,
36 //Post Processing Step: Resolves the product hierarchy for the result products.
37 // Requires 'productgrouplevels', 'referenceDate'
38 cgcloud.ProductResolution.ProcessStep.RESOLVEHIERARCHY,
39 //Post Processing Step: Resolves the tactic product excludes.
40 // Requires 'tactics'
41 cgcloud.ProductResolution.ProcessStep.RESOLVETACTICPRODUCTEXCLUDES,
42 //Post Processing Step: Resolves the bill of material components
43 cgcloud.ProductResolution.ProcessStep.RESOLVEBILLOFMATERIALS,
44 //Product Filter: Discontinued products will be filtered as per year offset. Requires considerdiscontinuedproductsyearoffset
45 cgcloud.ProductResolution.ProcessStep.DISCONTINUEDPRODUCTSFILTER
46});
47configuration.setAccountId('<accountId>');
48configuration.setPromotionId('<promotion>');
49configuration.setReferenceDate(Date.today());
50configuration.setCommitDate(Date.today());
51configuration.setDateFrom(Date.today().addDays(-5));
52configuration.setDateThru(Date.today().addDays(5));
53configuration.setProductGroupLevels('Category');
54configuration.setProductFilter(
55 new Map<String, Object>{
56 'cgcloud__criterion_1_product__c' => new List<Id>{
57 '<productid>'
58 }
59});
60configuration.setManualProducts(new List<Object>{
61 new Map<String, Object>{
62 'productid' => '<productid1>',
63 'included'=> true
64 },
65new Map<String, Object>{
66 'productid' => '<productid2>',
67 'included'=> false
68 }
69})
70configuration.setKAMStateFilter('bytimeframe'); // or setKAMStateFilter('bycommitdate')
71configuration.addTactic('<tacticId1>', new List<Id>('<productid1>')); //List of excluded products
72configuration.addTactic('<tacticId2>', new List<Id>('<productid2>'));
73configuration.setConsiderDiscontinuedProductsYearOffset(<lookbackPeriod>); // lookback period to filter discontinued products
74cgcloud.GetProductsCallout.GetProductsCalloutResponse response = request.execute(
75 cgcloud.TransactionHandler.getTransactionIdentifier(),
76 configuration
77);
78cgcloud.GetProductsCallout.DeNormalizedCalloutProductRows result = ((cgcloud.GetProductsCallout.GetProductDeNormalizedCalloutResponse) response).getResult();
79System.debug(JSON.serialize(result));