use of com.forgerock.openbanking.common.model.openbanking.domain.common.FRFinancialCreditor 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();
}
Aggregations