Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
CalculateAdjustments(CalculateAdjustmentsInput, claimId, coverageId)
Calculate adjustments for a loss item and determine the final payable amount for a
specific claim loss item.
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.CalculateAdjustmentsRepresentation CalculateAdjustments(ConnectApi.CalculateAdjustmentsInputRepresentation CalculateAdjustmentsInput, String claimId, String coverageId)
Parameters
- CalculateAdjustmentsInput
- Type: ConnectApi.CalculateAdjustmentsInputRepresentation
- Details for calculating adjustments.
- claimId
- Type: String
- ID of the claim for which the adjustments must be calculated.
- coverageId
- Type: String
- ID of the claim coverage.
Return Value
Example
Here's an example of how to invoke the Calculate Adjustments API by using Apex.
1public with sharing class CalculateAdjustments implements System.Callable {
2 public Object call(String action, Map<String, Object> args) {
3
4 Map<String, Object> bodyMap = new Map<String, Object>();
5
6 // Extract 'input' and 'output'
7 Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
8 Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
9
10 if (inputMap != null) {
11 if (inputMap.containsKey('claimId') && inputMap.get('claimId') != null) {
12 bodyMap.put('claimId', String.valueOf(inputMap.get('claimId')));
13 }
14 if (inputMap.containsKey('claimCoverageId') && inputMap.get('claimCoverageId') != null) {
15 bodyMap.put('claimCoverageId', String.valueOf(inputMap.get('claimCoverageId')));
16 }
17 if (inputMap.containsKey('claimedAmount') && inputMap.get('claimedAmount') != null) {
18 bodyMap.put('claimedAmount', String.valueOf(inputMap.get('claimedAmount')));
19 }
20 } else {
21 System.debug('No input map found in args');
22 }
23
24 String jsonBody = JSON.serialize(bodyMap);
25 System.debug('Final JSON Body: ' + jsonBody);
26
27 String str = postDataToExternalApi(bodyMap, jsonBody);
28 return outputMap.put('API Response: ', str);
29 }
30
31 public static String postDataToExternalApi(Map<String, Object> bodyMap, String jsonBody) {
32 HttpRequest request = new HttpRequest();
33 Http http = new Http();
34
35 String claimId = (String) bodyMap.get('claimId');
36 String claimCoverageId = (String) bodyMap.get('claimCoverageId');
37 String claimedAmount = (String) bodyMap.get('claimedAmount');
38
39 bodyMap.remove('claimId');
40 bodyMap.remove('claimCoverageId');
41
42 jsonBody = JSON.serialize(bodyMap);
43
44 if (String.isBlank(claimId) || String.isBlank(claimCoverageId) || String.isBlank(claimedAmount)) {
45 String errorMsg = 'Missing required fields - claimId: ' + claimId + ', claimCoverageId: ' + claimCoverageId + ', claimedAmount: ' + claimedAmount;
46 System.debug('Validation failed: ' + errorMsg);
47 return 'Error: ' + errorMsg;
48 }
49
50 // Build endpoint dynamically
51 String endpoint = 'callout:invokeUW/services/data/v65.0/connect/insurance/claims/'
52 + claimId + '/coverages/' + claimCoverageId + '/calculate-adjustments';
53 System.debug('>>> Dynamic Endpoint: ' + endpoint);
54
55 request.setEndpoint(endpoint);
56 request.setMethod('POST');
57 request.setHeader('Content-Type', 'application/json');
58 request.setTimeout(120000); // 2 mins
59 request.setBody(jsonBody);
60
61 try {
62 HttpResponse response = http.send(request);
63
64 System.debug('Status Code: ' + response.getStatusCode());
65 System.debug('Response Body: ' + response.getBody());
66
67 return response.getBody();
68 } catch (Exception e) {
69 System.debug('Exception: ' + e.getMessage());
70 return 'Exception: ' + e.getMessage();
71 }
72 }
73
74 // Sample test method
75 public static void testCalculateAdjustments() {
76 Map<String, Object> args = new Map<String, Object>();
77 Map<String, Object> input = new Map<String, Object>();
78 Map<String, Object> output = new Map<String, Object>();
79
80 input.put('claimId', '0Zkxx000000009hCAA');
81 input.put('claimCoverageId', '0kPxx000000006TEAQ');
82 input.put('claimedAmount', '1200.0');
83
84 args.put('input', input);
85 args.put('output', output);
86
87 CalculateAdjustments test = new CalculateAdjustments();
88 test.call('calculateAdjustments', args);
89 }
90}