Search in sources :

Example 1 with FRFinancialAgent

use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialAgent in project openbanking-aspsp by OpenBankingToolkit.

the class FRResponseDataRefundFactory method frInternationalResponseDataRefund.

/**
 * Creates a {@link FRInternationalResponseDataRefund}, so long as the provided {@link FRReadRefundAccount} is
 * set to 'Yes' and the initiation's debit account is null. Otherwise returns an empty {@link Optional}.
 *
 * @param frReadRefundAccount The {@link FRReadRefundAccount} indicating if a refund should be issued.
 * @param initiation          {@link FRDomesticDataInitiation} The payment's initiation data.
 * @return The {@link Optional} {@link FRDomesticResponseDataRefund} instance.
 */
public static Optional<FRInternationalResponseDataRefund> frInternationalResponseDataRefund(FRReadRefundAccount frReadRefundAccount, FRInternationalDataInitiation initiation) {
    if (hasRefund(frReadRefundAccount) && initiation.getDebtorAccount() != null) {
        FRAccountIdentifier debtorAccount = initiation.getDebtorAccount();
        FRFinancialCreditor creditor = initiation.getCreditor();
        FRFinancialAgent creditorAgent = initiation.getCreditorAgent();
        return Optional.of(FRInternationalResponseDataRefund.builder().account(FRAccountIdentifier.builder().schemeName(debtorAccount.getSchemeName()).identification(debtorAccount.getIdentification()).name(debtorAccount.getName()).secondaryIdentification(debtorAccount.getSecondaryIdentification()).build()).creditor(creditor == null ? null : FRFinancialCreditor.builder().name(creditor.getName()).postalAddress(creditor.getPostalAddress()).build()).agent(creditorAgent == null ? null : FRFinancialAgent.builder().schemeName(creditorAgent.getSchemeName()).identification(creditorAgent.getIdentification()).name(creditorAgent.getName()).postalAddress(creditorAgent.getPostalAddress()).build()).build());
    }
    return Optional.empty();
}
Also used : FRFinancialCreditor(com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialCreditor) FRAccountIdentifier(com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier) FRFinancialAgent(com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialAgent)

Aggregations

FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)1 FRFinancialAgent (com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialAgent)1 FRFinancialCreditor (com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialCreditor)1