use of uk.org.openbanking.datamodel.account.Meta in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalScheduledPaymentConsentsApiController method getInternationalScheduledPaymentConsentsConsentIdFundsConfirmation.
@Override
public ResponseEntity getInternationalScheduledPaymentConsentsConsentIdFundsConfirmation(String consentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String httpUrl, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRInternationalScheduledConsent> isScheduledConsent = internationalScheduledConsentRepository.findById(consentId);
if (!isScheduledConsent.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("International scheduled consent '" + consentId + "' can't be found");
}
FRInternationalScheduledConsent internationalScheduledConsent = isScheduledConsent.get();
// Check if funds are available on the account selected in consent
boolean areFundsAvailable = fundsAvailabilityService.isFundsAvailable(internationalScheduledConsent.getAccountId(), internationalScheduledConsent.getInitiation().getInstructedAmount().getAmount());
return ResponseEntity.status(HttpStatus.OK).body(new OBWriteFundsConfirmationResponse1().data(new OBWriteFundsConfirmationResponse1Data().fundsAvailableResult(new OBWriteFundsConfirmationResponse1DataFundsAvailableResult().fundsAvailable(areFundsAvailable).fundsAvailableDateTime(DateTime.now()))).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(new Meta()));
}
use of uk.org.openbanking.datamodel.account.Meta in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalScheduledPaymentConsentsApiController method getInternationalScheduledPaymentConsentsConsentIdFundsConfirmation.
public ResponseEntity getInternationalScheduledPaymentConsentsConsentIdFundsConfirmation(String consentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String httpUrl, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRInternationalScheduledConsent> isScheduledConsent = internationalScheduledConsentRepository.findById(consentId);
if (!isScheduledConsent.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("International scheduled consent '" + consentId + "' can't be found");
}
FRInternationalScheduledConsent internationalScheduledConsent = isScheduledConsent.get();
// Check if funds are available on the account selected in consent
boolean areFundsAvailable = fundsAvailabilityService.isFundsAvailable(internationalScheduledConsent.getAccountId(), internationalScheduledConsent.getInitiation().getInstructedAmount().getAmount());
return ResponseEntity.status(HttpStatus.OK).body(new OBWriteFundsConfirmationResponse1().data(new OBWriteFundsConfirmationResponse1Data().fundsAvailableResult(new OBWriteFundsConfirmationResponse1DataFundsAvailableResult().fundsAvailable(areFundsAvailable).fundsAvailableDateTime(DateTime.now()))).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(new Meta()));
}
use of uk.org.openbanking.datamodel.account.Meta in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticScheduledPaymentsApiController method responseEntity.
private OBWriteDomesticScheduledResponse4 responseEntity(FRDomesticScheduledPaymentSubmission frPaymentSubmission, FRDomesticScheduledConsent frDomesticScheduledConsent) {
FRReadRefundAccount readRefundAccount = frDomesticScheduledConsent.getDomesticScheduledConsent().getData().getReadRefundAccount();
FRWriteDomesticScheduledDataInitiation initiation = frPaymentSubmission.getDomesticScheduledPayment().getData().getInitiation();
Optional<FRDomesticResponseDataRefund> refund = frDomesticResponseDataRefund(readRefundAccount, initiation);
return new OBWriteDomesticScheduledResponse4().data(new OBWriteDomesticScheduledResponse4Data().domesticScheduledPaymentId(frPaymentSubmission.getId()).initiation(toOBWriteDomesticScheduled2DataInitiation(frDomesticScheduledConsent.getInitiation())).creationDateTime(frDomesticScheduledConsent.getCreated()).statusUpdateDateTime(frDomesticScheduledConsent.getStatusUpdate()).status(toOBWriteDomesticScheduledResponse4DataStatus(frDomesticScheduledConsent.getStatus())).consentId(frDomesticScheduledConsent.getId()).refund(refund.map(FRResponseDataRefundConverter::toOBWriteDomesticResponse4DataRefund).orElse(null))).links(resourceLinkService.toSelfLink(frPaymentSubmission, discovery -> getVersion(discovery).getGetDomesticScheduledPayment())).meta(new Meta());
}
use of uk.org.openbanking.datamodel.account.Meta in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentConsentsApiController method getInternationalPaymentConsentsConsentIdFundsConfirmation.
public ResponseEntity getInternationalPaymentConsentsConsentIdFundsConfirmation(String consentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String httpUrl, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRInternationalConsent> isInternationalConsent = internationalConsentRepository.findById(consentId);
if (!isInternationalConsent.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("International consent '" + consentId + "' can't be found");
}
FRInternationalConsent internationalConsent = isInternationalConsent.get();
// Check if funds are available on the account selected in consent
boolean areFundsAvailable = fundsAvailabilityService.isFundsAvailable(internationalConsent.getAccountId(), internationalConsent.getInitiation().getInstructedAmount().getAmount());
return ResponseEntity.status(HttpStatus.OK).body(new OBWriteFundsConfirmationResponse1().data(new OBWriteFundsConfirmationResponse1Data().fundsAvailableResult(new OBWriteFundsConfirmationResponse1DataFundsAvailableResult().fundsAvailable(areFundsAvailable).fundsAvailableDateTime(DateTime.now()))).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(new Meta()));
}
use of uk.org.openbanking.datamodel.account.Meta in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentsApiController method responseEntity.
private OBWriteInternationalResponse5 responseEntity(FRInternationalPaymentSubmission frPaymentSubmission, FRInternationalConsent frInternationalConsent) {
FRReadRefundAccount readRefundAccount = frInternationalConsent.getInternationalConsent().getData().getReadRefundAccount();
FRWriteInternationalDataInitiation initiation = frPaymentSubmission.getInternationalPayment().getData().getInitiation();
Optional<FRInternationalResponseDataRefund> refund = frInternationalResponseDataRefund(readRefundAccount, initiation);
return new OBWriteInternationalResponse5().data(new OBWriteInternationalResponse5Data().internationalPaymentId(frPaymentSubmission.getId()).initiation(toOBWriteInternational3DataInitiation(frPaymentSubmission.getInternationalPayment().getData().getInitiation())).creationDateTime(frInternationalConsent.getCreated()).statusUpdateDateTime(frInternationalConsent.getStatusUpdate()).status(toOBWriteInternationalResponse5DataStatus(frInternationalConsent.getStatus())).consentId(frInternationalConsent.getId()).debtor(toOBCashAccountDebtor4(frInternationalConsent.getInitiation().getDebtorAccount())).exchangeRateInformation(toOBWriteInternationalConsentResponse6DataExchangeRateInformation(frInternationalConsent.getCalculatedExchangeRate())).refund(refund.map(FRResponseDataRefundConverter::toOBWriteInternationalResponse5DataRefund).orElse(null))).links(resourceLinkService.toSelfLink(frPaymentSubmission, discovery -> getVersion(discovery).getGetInternationalPayment())).meta(new Meta());
}
Aggregations