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.

Example

Class Definition

/**
 * Callable wrapper to exercise the UFA (User Financial Authority) Connect API:
 *   POST /connect/insurance/claims/payment-details/${paymentDetailId}/check-financial-authority
 *
 * Backed by CheckFinancialAuthorityResourceImpl -> CheckFinancialAuthorityService.
 *
 * Mirrors the EditClaimCoveragePaymentDetailCallable pattern. All debug output is
 * prefixed with [UFA] so it is easy to grep in the debug logs.
 */
public with sharing class CheckFinancialAuthorityCallable implements System.Callable {

    private static final String LOG_PREFIX = '[UFA] ';

    public Object call(String action, Map<String, Object> args) {
        // Retrieve the input and output maps from the arguments
        Map<String, Object> inputMap  = (Map<String, Object>) args.get('input');
        Map<String, Object> outputMap = (Map<String, Object>) args.get('output');

        if (action == 'checkFinancialAuthority') {
            // paymentDetailId is the ClaimCoveragePaymentDetail record Id to evaluate.
            // It maps to the ${paymentDetailId} URL path parameter.
            String paymentDetailId = (String) inputMap.get('paymentDetailId');

            // The CheckFinancialAuthorityInputRep body is currently EMPTY (no fields).
            // We still build/accept one so the call site matches the generated signature.
            ConnectApi.CheckFinancialAuthorityInputRep checkInputRep =
                (ConnectApi.CheckFinancialAuthorityInputRep) inputMap.get('CheckFinancialAuthorityInput');
            if (checkInputRep == null) {
                checkInputRep = new ConnectApi.CheckFinancialAuthorityInputRep();
            }

            System.debug(LOG_PREFIX + '==== Start CheckFinancialAuthority Connect API call ====');
            System.debug(LOG_PREFIX + 'Running as user: ' + UserInfo.getUserId() + ' (' + UserInfo.getName() + ')');
            System.debug(LOG_PREFIX + 'paymentDetailId (ClaimCoveragePaymentDetail Id): ' + paymentDetailId);

            ConnectApi.CheckFinancialAuthorityRep checkResponse;

            try {
                // Generated Apex signature: (paymentDetailId, input) — path param first.
                checkResponse = ConnectApi.InsuranceClaimFamily.CheckFinancialAuthority(
                    paymentDetailId,
                    checkInputRep
                );

                System.debug(LOG_PREFIX + 'CheckFinancialAuthority completed. Raw response: ' + checkResponse);

                // Surface every field the output representation returns.
                outputMap.put('checkResponse', checkResponse);
                if (checkResponse != null) {
                    outputMap.put('isSuccess',                     checkResponse.isSuccess);
                    outputMap.put('requestedBy',                   checkResponse.requestedBy);
                    outputMap.put('hasFinancialAuthority',         checkResponse.hasFinancialAuthority);
                    outputMap.put('isFinancialAuthorityConfigured', checkResponse.isFinancialAuthorityConfigured);
                    outputMap.put('isPaymentAllowed',              checkResponse.isPaymentAllowed);
                    outputMap.put('maximumApprovalAmount',         checkResponse.maximumApprovalAmount);

                    System.debug(LOG_PREFIX + 'isSuccess                     = ' + checkResponse.isSuccess);
                    System.debug(LOG_PREFIX + 'requestedBy                   = ' + checkResponse.requestedBy);
                    System.debug(LOG_PREFIX + 'hasFinancialAuthority         = ' + checkResponse.hasFinancialAuthority);
                    System.debug(LOG_PREFIX + 'isFinancialAuthorityConfigured= ' + checkResponse.isFinancialAuthorityConfigured);
                    System.debug(LOG_PREFIX + 'isPaymentAllowed              = ' + checkResponse.isPaymentAllowed);
                    System.debug(LOG_PREFIX + 'maximumApprovalAmount         = ' + checkResponse.maximumApprovalAmount);

                    if (checkResponse.errors != null && !checkResponse.errors.isEmpty()) {
                        outputMap.put('errors', checkResponse.errors);
                        System.debug(LOG_PREFIX + 'Errors returned by service:');
                        for (ConnectApi.ErrorDetail err : checkResponse.errors) {
                            System.debug(LOG_PREFIX + '   code=' + err.code + ', message=' + err.message);
                        }
                    } else {
                        System.debug(LOG_PREFIX + 'No errors returned.');
                    }
                }
            } catch (Exception e) {
                System.debug(LOG_PREFIX + 'EXCEPTION while calling CheckFinancialAuthority: ' + e.getMessage());
                System.debug(LOG_PREFIX + 'Stack trace: ' + e.getStackTraceString());
                outputMap.put('error', e.getMessage());
                outputMap.put('isSuccess', false);
            }

            System.debug(LOG_PREFIX + '==== End CheckFinancialAuthority Connect API call ====');
            return checkResponse;
        }

        System.debug(LOG_PREFIX + 'Unrecognized action: ' + action);
        return null;
    }
}    

Usage Example

/**
 * Execute-Anonymous script to test the UFA CheckFinancialAuthority Connect API
 * via CheckFinancialAuthorityCallable.
 *
 * To view logs: open Developer Console -> Logs, or set a Debug Level, then
 * filter the log for the [UFA] prefix.
 */

CheckFinancialAuthorityCallable callable = new CheckFinancialAuthorityCallable();

// ----- Input -----
Map<String, Object> input = new Map<String, Object>();

// The ClaimCoveragePaymentDetail record Id to evaluate (maps to ${paymentDetailId}).
input.put('paymentDetailId', '0l2SB000000CLsMYAW');   // <-- replace with a real CCPD Id

// The CheckFinancialAuthorityInputRep body is currently empty (no fields to set).
// Provided here for completeness / future-proofing.
ConnectApi.CheckFinancialAuthorityInputRep checkInputRep =
    new ConnectApi.CheckFinancialAuthorityInputRep();
input.put('CheckFinancialAuthorityInput', checkInputRep);

// ----- Output -----
Map<String, Object> output = new Map<String, Object>();

// ----- Args -----
Map<String, Object> args = new Map<String, Object>();
args.put('input', input);
args.put('output', output);

System.debug('[UFA-TEST] Invoking checkFinancialAuthority action...');
Object result = callable.call('checkFinancialAuthority', args);

// ----- Inspect result -----
if (result != null) {
    ConnectApi.CheckFinancialAuthorityRep checkData = (ConnectApi.CheckFinancialAuthorityRep) result;
    System.debug('[UFA-TEST] Response received: ' + checkData);
    System.debug('[UFA-TEST] isSuccess                      = ' + checkData.isSuccess);
    System.debug('[UFA-TEST] requestedBy                    = ' + checkData.requestedBy);
    System.debug('[UFA-TEST] hasFinancialAuthority          = ' + checkData.hasFinancialAuthority);
    System.debug('[UFA-TEST] isFinancialAuthorityConfigured = ' + checkData.isFinancialAuthorityConfigured);
    System.debug('[UFA-TEST] isPaymentAllowed               = ' + checkData.isPaymentAllowed);
    System.debug('[UFA-TEST] maximumApprovalAmount          = ' + checkData.maximumApprovalAmount);

    if (checkData.isSuccess == true) {
        if (checkData.isPaymentAllowed == true) {
            System.debug('[UFA-TEST] RESULT: Payment IS allowed for this CCPD.');
        } else {
            System.debug('[UFA-TEST] RESULT: Payment is NOT allowed for this CCPD.');
        }
    } else {
        System.debug('[UFA-TEST] RESULT: API reported failure.');
    }

    if (checkData.errors != null && !checkData.errors.isEmpty()) {
        for (ConnectApi.ErrorDetail err : checkData.errors) {
            System.debug('[UFA-TEST] Error -> code=' + err.code + ', message=' + err.message);
        }
    }
} else {
    System.debug('[UFA-TEST] No result returned. error=' + output.get('error'));
}