Search in sources :

Example 56 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalStandingOrdersApiController method createInternationalStandingOrders.

@Override
public ResponseEntity<OBWriteInternationalStandingOrderResponse3> createInternationalStandingOrders(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalStandingOrder3 OBWriteInternationalStandingOrder3Param, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "Every request will be processed only once per x-idempotency-key.  The Idempotency Key will be valid for 24 hours.", required = true) @RequestHeader(value = "x-idempotency-key", required = true) String xIdempotencyKey, @ApiParam(value = "A detached JWS signature of the body of the payload.", required = true) @RequestHeader(value = "x-jws-signature", required = true) String xJwsSignature, @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = OBWriteInternationalStandingOrder3Param.getData().getConsentId();
    FRInternationalStandingOrderConsent payment = paymentsService.getPayment(consentId);
    return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).payment(payment).principal(principal).filters(f -> {
        f.verifyPaymentIdWithAccessToken();
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyPaymentStatus();
        f.verifyRiskAndInitiation(toFRWriteInternationalStandingOrderDataInitiation(OBWriteInternationalStandingOrder3Param.getData().getInitiation()), toFRRisk(OBWriteInternationalStandingOrder3Param.getRisk()));
        f.verifyJwsDetachedSignature(xJwsSignature, request);
    }).execute((String tppId) -> {
        // Modify the status of the payment
        log.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        log.info("Updating payment");
        paymentsService.updatePayment(payment);
        FRWriteInternationalStandingOrderDataInitiation initiation = payment.getInitiation();
        FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(initiation.getCreditorAccount()).frequency(initiation.getFrequency()).reference(initiation.getReference()).firstPaymentDateTime(initiation.getFirstPaymentDateTime()).firstPaymentAmount(initiation.getInstructedAmount()).nextPaymentAmount(initiation.getInstructedAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(initiation.getFirstPaymentDateTime(), initiation.getFrequency())).finalPaymentDateTime(initiation.getFinalPaymentDateTime()).finalPaymentAmount(initiation.getInstructedAmount()).standingOrderId(payment.getId()).build();
        String pispId = tppStoreService.findPispIdByTppId(tppId);
        standingOrderService.createStandingOrder(standingOrder, pispId);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalStandingOrderResponse3.class, OBWriteInternationalStandingOrder3Param);
    });
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) OBWriteInternationalStandingOrderResponse3(uk.org.openbanking.datamodel.payment.OBWriteInternationalStandingOrderResponse3) ApiParam(io.swagger.annotations.ApiParam) FrequencyService(com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) RequestBody(org.springframework.web.bind.annotation.RequestBody) Valid(javax.validation.Valid) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) FRWriteInternationalStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrderDataInitiation) InternationalStandingOrderService(com.forgerock.openbanking.common.services.store.payment.InternationalStandingOrderService) HttpHeaders(org.springframework.http.HttpHeaders) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) OBWriteInternationalStandingOrder3(uk.org.openbanking.datamodel.payment.OBWriteInternationalStandingOrder3) FRWriteInternationalStandingOrderConsentConverter.toFRWriteInternationalStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalStandingOrderConsentConverter.toFRWriteInternationalStandingOrderDataInitiation) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) FRInternationalStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent) StandingOrderService(com.forgerock.openbanking.common.services.store.account.standingorder.StandingOrderService) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) FRPaymentRiskConverter.toFRRisk(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk) Collections(java.util.Collections) TppStoreService(com.forgerock.openbanking.common.services.store.tpp.TppStoreService) HttpHeaders(org.springframework.http.HttpHeaders) FRInternationalStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent) FRWriteInternationalStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrderDataInitiation) FRWriteInternationalStandingOrderConsentConverter.toFRWriteInternationalStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalStandingOrderConsentConverter.toFRWriteInternationalStandingOrderDataInitiation) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData)

Example 57 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getAccountStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder2> getAccountStandingOrders(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Read standing orders for account {} with minimumPermissions {}", accountId, permissions);
    Page<FRStandingOrder> standingOrdersResponse = frStandingOrderRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_STANDING_ORDERS));
    List<OBStandingOrder2> standingOrders = standingOrdersResponse.stream().map(so -> toOBStandingOrder2(so.getStandingOrder())).collect(Collectors.toList());
    int totalPages = standingOrdersResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder2().data(new OBReadStandingOrder2Data().standingOrder(standingOrders)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : FRStandingOrderConverter.toOBStandingOrder2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder2) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) OBStandingOrder2(uk.org.openbanking.datamodel.account.OBStandingOrder2) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) Value(org.springframework.beans.factory.annotation.Value) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) OBReadStandingOrder2Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder2Data) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) FRStandingOrderRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.standingorders.FRStandingOrderRepository) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) List(java.util.List) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) OBReadStandingOrder2(uk.org.openbanking.datamodel.account.OBReadStandingOrder2) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadStandingOrder2(uk.org.openbanking.datamodel.account.OBReadStandingOrder2) OBReadStandingOrder2Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder2Data) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) FRStandingOrderConverter.toOBStandingOrder2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder2) OBStandingOrder2(uk.org.openbanking.datamodel.account.OBStandingOrder2)

Example 58 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder2> getStandingOrders(@ApiParam(value = "The unique id of the ASPSP to which the request is issued. " + "The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are " + "represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-account-ids", required = true) List<String> accountIds, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Reading standing orders from account ids {}", accountIds);
    Page<FRStandingOrder> standingOrdersResponse = frStandingOrderRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_STANDING_ORDERS));
    List<OBStandingOrder2> standingOrders = standingOrdersResponse.stream().map(so -> toOBStandingOrder2(so.getStandingOrder())).collect(Collectors.toList());
    int totalPages = standingOrdersResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder2().data(new OBReadStandingOrder2Data().standingOrder(standingOrders)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : FRStandingOrderConverter.toOBStandingOrder2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder2) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) OBStandingOrder2(uk.org.openbanking.datamodel.account.OBStandingOrder2) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) Value(org.springframework.beans.factory.annotation.Value) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) OBReadStandingOrder2Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder2Data) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) FRStandingOrderRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.standingorders.FRStandingOrderRepository) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) List(java.util.List) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) OBReadStandingOrder2(uk.org.openbanking.datamodel.account.OBReadStandingOrder2) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadStandingOrder2(uk.org.openbanking.datamodel.account.OBReadStandingOrder2) OBReadStandingOrder2Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder2Data) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) FRStandingOrderConverter.toOBStandingOrder2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder2) OBStandingOrder2(uk.org.openbanking.datamodel.account.OBStandingOrder2)

Example 59 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class BeneficiariesApiController method getAccountBeneficiaries.

@Override
public ResponseEntity<OBReadBeneficiary1> getAccountBeneficiaries(@PathVariable("AccountId") String accountId, @RequestParam(value = "page", defaultValue = "0") int page, @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @RequestHeader(value = "Authorization", required = true) String authorization, @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) {
    LOGGER.info("Read beneficiaries for account  {} with minimumPermissions {}", accountId, permissions);
    Page<FRBeneficiary> beneficiariesResponse = frBeneficiaryRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_BENEFICIARIES));
    List<OBBeneficiary1> beneficiaries = beneficiariesResponse.stream().map(b -> toOBBeneficiary1(b.getBeneficiary())).collect(Collectors.toList());
    int totalPages = beneficiariesResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadBeneficiary1().data(new OBReadDataBeneficiary1().beneficiary(beneficiaries)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) FRAccountBeneficiaryConverter.toOBBeneficiary1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRAccountBeneficiaryConverter.toOBBeneficiary1) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) Value(org.springframework.beans.factory.annotation.Value) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) OBReadDataBeneficiary1(uk.org.openbanking.datamodel.account.OBReadDataBeneficiary1) FRBeneficiaryRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.beneficiaries.FRBeneficiaryRepository) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) FRBeneficiary(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRBeneficiary) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) OBReadBeneficiary1(uk.org.openbanking.datamodel.account.OBReadBeneficiary1) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) List(java.util.List) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBBeneficiary1(uk.org.openbanking.datamodel.account.OBBeneficiary1) OBReadDataBeneficiary1(uk.org.openbanking.datamodel.account.OBReadDataBeneficiary1) FRAccountBeneficiaryConverter.toOBBeneficiary1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRAccountBeneficiaryConverter.toOBBeneficiary1) OBBeneficiary1(uk.org.openbanking.datamodel.account.OBBeneficiary1) OBReadBeneficiary1(uk.org.openbanking.datamodel.account.OBReadBeneficiary1) FRBeneficiary(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRBeneficiary)

Example 60 with HTTP_DATE_FORMAT

use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder1> getStandingOrders(@ApiParam(value = "The unique id of the ASPSP to which the request is issued. " + "The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP.  All dates in the HTTP headers are " + "represented as RFC 7231 Full Dates. An example is below:  Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-account-ids", required = true) List<String> accountIds, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Reading standing orders from account ids {}", accountIds);
    Page<FRStandingOrder> standingOrdersResponse = frStandingOrderRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_STANDING_ORDERS));
    List<OBStandingOrder1> standingOrders = standingOrdersResponse.stream().map(so -> toOBStandingOrder1(so.getStandingOrder())).collect(Collectors.toList());
    int totalPages = standingOrdersResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder1().data(new OBReadDataStandingOrder1().standingOrder(standingOrders)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) FRStandingOrderConverter.toOBStandingOrder1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder1) RequestParam(org.springframework.web.bind.annotation.RequestParam) OBStandingOrder1(uk.org.openbanking.datamodel.account.OBStandingOrder1) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) OBReadDataStandingOrder1(uk.org.openbanking.datamodel.account.OBReadDataStandingOrder1) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) Value(org.springframework.beans.factory.annotation.Value) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) FRStandingOrderRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.standingorders.FRStandingOrderRepository) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) List(java.util.List) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) OBReadStandingOrder1(uk.org.openbanking.datamodel.account.OBReadStandingOrder1) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadDataStandingOrder1(uk.org.openbanking.datamodel.account.OBReadDataStandingOrder1) OBReadStandingOrder1(uk.org.openbanking.datamodel.account.OBReadStandingOrder1) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) FRStandingOrderConverter.toOBStandingOrder1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder1) OBStandingOrder1(uk.org.openbanking.datamodel.account.OBStandingOrder1)

Aggregations

HTTP_DATE_FORMAT (com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT)63 DateTime (org.joda.time.DateTime)63 DateTimeFormat (org.springframework.format.annotation.DateTimeFormat)63 ResponseEntity (org.springframework.http.ResponseEntity)63 Controller (org.springframework.stereotype.Controller)63 PathVariable (org.springframework.web.bind.annotation.PathVariable)63 RequestHeader (org.springframework.web.bind.annotation.RequestHeader)63 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)62 ApiParam (io.swagger.annotations.ApiParam)62 Logger (org.slf4j.Logger)50 LoggerFactory (org.slf4j.LoggerFactory)50 Collections (java.util.Collections)43 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)42 Principal (java.security.Principal)42 HttpServletRequest (javax.servlet.http.HttpServletRequest)42 Valid (javax.validation.Valid)42 HttpHeaders (org.springframework.http.HttpHeaders)42 RequestBody (org.springframework.web.bind.annotation.RequestBody)42 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)41 Autowired (org.springframework.beans.factory.annotation.Autowired)38