Newer Version Available
CreateClaimCoveragePaymentDetail(CreateClaimCoveragePaymentDetailInput, claimId, coverageId)
Create a claim coverage payment detail record.
API Version
65.0
Requires Chatter
No
Signature
public static ConnectApi.CreateClaimCoveragePaymentDetailRep CreateClaimCoveragePaymentDetail(ConnectApi.CreateClaimCovPaymentDetailInputRep CreateClaimCoveragePaymentDetailInput, String claimId, String coverageId)
Parameters
- CreateClaimCoveragePaymentDetailInput
- Type: ConnectApi.CreateClaimCovPaymentDetailInputRep
- Representation details to create the claim coverage payment detail record.
- claimId
- Type: String
- ID of the claim.
- coverageId
- Type: String
- ID of the claim coverage.
Return Value
Example
Here's an example of how to invoke the Create CCPD API by using Apex.
1
2public with sharing class CreateCCPDIPTest3 implements System.Callable {
3 public Object call(String action, Map<String, Object> args) {
4 System.debug('>>> Action: ' + action);
5 System.debug('>>> Args: ' + JSON.serializePretty(args));
6
7 Map<String, Object> bodyMap = new Map<String, Object>();
8
9 // Extract 'input' and 'output'
10 Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
11 Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
12
13 if (inputMap != null) {
14 if (inputMap.containsKey('claimId') && inputMap.get('claimId') != null) {
15 bodyMap.put('claimId', String.valueOf(inputMap.get('claimId')));
16 }
17 if (inputMap.containsKey('claimCoverageId') && inputMap.get('claimCoverageId') != null) {
18 bodyMap.put('claimCoverageId', String.valueOf(inputMap.get('claimCoverageId')));
19 }
20 if (inputMap.containsKey('claimedAmount') && inputMap.get('claimedAmount') != null) {
21 bodyMap.put('claimedAmount', String.valueOf(inputMap.get('claimedAmount')));
22 }
23 if (inputMap.containsKey('coveragePaymentType') && inputMap.get('coveragePaymentType') != null) {
24 bodyMap.put('coveragePaymentType', String.valueOf(inputMap.get('coveragePaymentType')));
25 }
26 if (inputMap.containsKey('adjustedAmount') && inputMap.get('adjustedAmount') != null) {
27 bodyMap.put('adjustedAmount', String.valueOf(inputMap.get('adjustedAmount')));
28 }
29 } else {
30 System.debug('⚠️ No input map found in args');
31 }
32
33 String jsonBody = JSON.serialize(bodyMap);
34 System.debug('>>> Final JSON Body: ' + jsonBody);
35
36 String str = postDataToExternalApi(bodyMap, jsonBody);
37 return outputMap.put('response', str);
38 }
39
40 public static String postDataToExternalApi(Map<String, Object> bodyMap, String jsonBody) {
41 HttpRequest request = new HttpRequest();
42 Http http = new Http();
43
44 String claimId = (String) bodyMap.get('claimId');
45 String claimCoverageId = (String) bodyMap.get('claimCoverageId');
46
47 bodyMap.remove('claimId');
48 bodyMap.remove('claimCoverageId');
49
50 jsonBody = JSON.serialize(bodyMap);
51 System.debug('>>> Final JSON Body: ' + jsonBody);
52
53 if (String.isBlank(claimId) || String.isBlank(claimCoverageId)) {
54 String errorMsg = 'Missing required fields - claimId: ' + claimId + ', claimCoverageId: ' + claimCoverageId;
55 System.debug('⚠️ ' + errorMsg);
56 return 'Error: ' + errorMsg;
57 }
58
59 // ✅ Build endpoint dynamically
60 String endpoint = 'callout:invokeUW/services/data/v65.0/connect/insurance/claims/'
61 + claimId + '/coverages/' + claimCoverageId + '/payment-details';
62 System.debug('>>> Dynamic Endpoint: ' + endpoint);
63
64 request.setEndpoint(endpoint);
65 request.setMethod('POST');
66 request.setHeader('Content-Type', 'application/json');
67 request.setTimeout(120000); // 2 mins
68 request.setBody(jsonBody);
69
70 try {
71 HttpResponse response = http.send(request);
72
73 System.debug('>>> Status Code: ' + response.getStatusCode());
74 System.debug('>>> Response Body: ' + response.getBody());
75
76 return response.getBody();
77 } catch (Exception e) {
78 System.debug('🔥 Exception: ' + e.getMessage());
79 return 'Exception: ' + e.getMessage();
80 }
81 }
82
83 // Sample test method
84 public static void testCreateCCPD() {
85 Map<String, Object> args = new Map<String, Object>();
86 Map<String, Object> input = new Map<String, Object>();
87 Map<String, Object> output = new Map<String, Object>();
88
89 input.put('claimId', '0Zkxx000000009hCAA');
90 input.put('claimCoverageId', '0kPxx000000006TEAQ');
91 input.put('claimedAmount', '1200.0');
92 input.put('coveragePaymentType', 'Loss');
93 input.put('adjustedAmount', '1200.0');
94
95 args.put('input', input);
96 args.put('output', output);
97
98 CreateCCPDIPTest1 test = new CreateCCPDIPTest1();
99 test.call('createCCPD', args);
100 }
101}