CheckFinancialAuthority(paymentDetailId)
Check whether the current user has the financial authority to pay a specified claim
coverage payment detail record.
API Version
68.0
Requires Chatter
No
Signature
public static ConnectApi.CheckFinancialAuthorityRep CheckFinancialAuthority(String paymentDetailId)
Parameters
paymentDetailId
- Type: String
- ID of the claim coverage payment detail record to evaluate.
Return Value
Example
Class Definition
1/**
2 * Callable wrapper to exercise the UFA (User Financial Authority) Connect API:
3 * POST /connect/insurance/claims/payment-details/${paymentDetailId}/check-financial-authority
4 *
5 * Backed by CheckFinancialAuthorityResourceImpl -> CheckFinancialAuthorityService.
6 *
7 * Mirrors the EditClaimCoveragePaymentDetailCallable pattern. All debug output is
8 * prefixed with [UFA] so it is easy to grep in the debug logs.
9 */
10public with sharing class CheckFinancialAuthorityCallable implements System.Callable {
11
12 private static final String LOG_PREFIX = '[UFA] ';
13
14 public Object call(String action, Map<String, Object> args) {
15 // Retrieve the input and output maps from the arguments
16 Map<String, Object> inputMap = (Map<String, Object>) args.get('input');
17 Map<String, Object> outputMap = (Map<String, Object>) args.get('output');
18
19 if (action == 'checkFinancialAuthority') {
20 // paymentDetailId is the ClaimCoveragePaymentDetail record Id to evaluate.
21 // It maps to the ${paymentDetailId} URL path parameter.
22 String paymentDetailId = (String) inputMap.get('paymentDetailId');
23
24 // The CheckFinancialAuthorityInputRep body is currently EMPTY (no fields).
25 // We still build/accept one so the call site matches the generated signature.
26 ConnectApi.CheckFinancialAuthorityInputRep checkInputRep =
27 (ConnectApi.CheckFinancialAuthorityInputRep) inputMap.get('CheckFinancialAuthorityInput');
28 if (checkInputRep == null) {
29 checkInputRep = new ConnectApi.CheckFinancialAuthorityInputRep();
30 }
31
32 System.debug(LOG_PREFIX + '==== Start CheckFinancialAuthority Connect API call ====');
33 System.debug(LOG_PREFIX + 'Running as user: ' + UserInfo.getUserId() + ' (' + UserInfo.getName() + ')');
34 System.debug(LOG_PREFIX + 'paymentDetailId (ClaimCoveragePaymentDetail Id): ' + paymentDetailId);
35
36 ConnectApi.CheckFinancialAuthorityRep checkResponse;
37
38 try {
39 // Generated Apex signature: (paymentDetailId, input) — path param first.
40 checkResponse = ConnectApi.InsuranceClaimFamily.CheckFinancialAuthority(
41 paymentDetailId,
42 checkInputRep
43 );
44
45 System.debug(LOG_PREFIX + 'CheckFinancialAuthority completed. Raw response: ' + checkResponse);
46
47 // Surface every field the output representation returns.
48 outputMap.put('checkResponse', checkResponse);
49 if (checkResponse != null) {
50 outputMap.put('isSuccess', checkResponse.isSuccess);
51 outputMap.put('requestedBy', checkResponse.requestedBy);
52 outputMap.put('hasFinancialAuthority', checkResponse.hasFinancialAuthority);
53 outputMap.put('isFinancialAuthorityConfigured', checkResponse.isFinancialAuthorityConfigured);
54 outputMap.put('isPaymentAllowed', checkResponse.isPaymentAllowed);
55 outputMap.put('maximumApprovalAmount', checkResponse.maximumApprovalAmount);
56
57 System.debug(LOG_PREFIX + 'isSuccess = ' + checkResponse.isSuccess);
58 System.debug(LOG_PREFIX + 'requestedBy = ' + checkResponse.requestedBy);
59 System.debug(LOG_PREFIX + 'hasFinancialAuthority = ' + checkResponse.hasFinancialAuthority);
60 System.debug(LOG_PREFIX + 'isFinancialAuthorityConfigured= ' + checkResponse.isFinancialAuthorityConfigured);
61 System.debug(LOG_PREFIX + 'isPaymentAllowed = ' + checkResponse.isPaymentAllowed);
62 System.debug(LOG_PREFIX + 'maximumApprovalAmount = ' + checkResponse.maximumApprovalAmount);
63
64 if (checkResponse.errors != null && !checkResponse.errors.isEmpty()) {
65 outputMap.put('errors', checkResponse.errors);
66 System.debug(LOG_PREFIX + 'Errors returned by service:');
67 for (ConnectApi.ErrorDetail err : checkResponse.errors) {
68 System.debug(LOG_PREFIX + ' code=' + err.code + ', message=' + err.message);
69 }
70 } else {
71 System.debug(LOG_PREFIX + 'No errors returned.');
72 }
73 }
74 } catch (Exception e) {
75 System.debug(LOG_PREFIX + 'EXCEPTION while calling CheckFinancialAuthority: ' + e.getMessage());
76 System.debug(LOG_PREFIX + 'Stack trace: ' + e.getStackTraceString());
77 outputMap.put('error', e.getMessage());
78 outputMap.put('isSuccess', false);
79 }
80
81 System.debug(LOG_PREFIX + '==== End CheckFinancialAuthority Connect API call ====');
82 return checkResponse;
83 }
84
85 System.debug(LOG_PREFIX + 'Unrecognized action: ' + action);
86 return null;
87 }
88}Usage Example
1/**
2 * Execute-Anonymous script to test the UFA CheckFinancialAuthority Connect API
3 * via CheckFinancialAuthorityCallable.
4 *
5 * To view logs: open Developer Console -> Logs, or set a Debug Level, then
6 * filter the log for the [UFA] prefix.
7 */
8
9CheckFinancialAuthorityCallable callable = new CheckFinancialAuthorityCallable();
10
11// ----- Input -----
12Map<String, Object> input = new Map<String, Object>();
13
14// The ClaimCoveragePaymentDetail record Id to evaluate (maps to ${paymentDetailId}).
15input.put('paymentDetailId', '0l2SB000000CLsMYAW'); // <-- replace with a real CCPD Id
16
17// The CheckFinancialAuthorityInputRep body is currently empty (no fields to set).
18// Provided here for completeness / future-proofing.
19ConnectApi.CheckFinancialAuthorityInputRep checkInputRep =
20 new ConnectApi.CheckFinancialAuthorityInputRep();
21input.put('CheckFinancialAuthorityInput', checkInputRep);
22
23// ----- Output -----
24Map<String, Object> output = new Map<String, Object>();
25
26// ----- Args -----
27Map<String, Object> args = new Map<String, Object>();
28args.put('input', input);
29args.put('output', output);
30
31System.debug('[UFA-TEST] Invoking checkFinancialAuthority action...');
32Object result = callable.call('checkFinancialAuthority', args);
33
34// ----- Inspect result -----
35if (result != null) {
36 ConnectApi.CheckFinancialAuthorityRep checkData = (ConnectApi.CheckFinancialAuthorityRep) result;
37 System.debug('[UFA-TEST] Response received: ' + checkData);
38 System.debug('[UFA-TEST] isSuccess = ' + checkData.isSuccess);
39 System.debug('[UFA-TEST] requestedBy = ' + checkData.requestedBy);
40 System.debug('[UFA-TEST] hasFinancialAuthority = ' + checkData.hasFinancialAuthority);
41 System.debug('[UFA-TEST] isFinancialAuthorityConfigured = ' + checkData.isFinancialAuthorityConfigured);
42 System.debug('[UFA-TEST] isPaymentAllowed = ' + checkData.isPaymentAllowed);
43 System.debug('[UFA-TEST] maximumApprovalAmount = ' + checkData.maximumApprovalAmount);
44
45 if (checkData.isSuccess == true) {
46 if (checkData.isPaymentAllowed == true) {
47 System.debug('[UFA-TEST] RESULT: Payment IS allowed for this CCPD.');
48 } else {
49 System.debug('[UFA-TEST] RESULT: Payment is NOT allowed for this CCPD.');
50 }
51 } else {
52 System.debug('[UFA-TEST] RESULT: API reported failure.');
53 }
54
55 if (checkData.errors != null && !checkData.errors.isEmpty()) {
56 for (ConnectApi.ErrorDetail err : checkData.errors) {
57 System.debug('[UFA-TEST] Error -> code=' + err.code + ', message=' + err.message);
58 }
59 }
60} else {
61 System.debug('[UFA-TEST] No result returned. error=' + output.get('error'));
62}