Search in sources :

Example 11 with FRStandingOrder

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getAccountStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder4> 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> standingOrders = frStandingOrderRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_STANDING_ORDERS));
    int totalPages = standingOrders.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder4().data(new OBReadStandingOrder4Data().standingOrder(standingOrders.getContent().stream().map(FRStandingOrder::getStandingOrder).map(FRStandingOrderConverter::toOBStandingOrder4).map(so -> accountDataInternalIdFilter.apply(so)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : OBReadStandingOrder4(uk.org.openbanking.datamodel.account.OBReadStandingOrder4) OBReadStandingOrder4Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder4Data) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder)

Example 12 with FRStandingOrder

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getAccountStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder3> 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<OBStandingOrder3> standingOrders = standingOrdersResponse.stream().map(so -> toOBStandingOrder3(so.getStandingOrder())).map(so -> accountDataInternalIdFilter.apply(so)).collect(Collectors.toList());
    int totalPages = standingOrdersResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder3().data(new OBReadStandingOrder3Data().standingOrder(standingOrders)).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) FRStandingOrderConverter.toOBStandingOrder3(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder3) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) OBStandingOrder3(uk.org.openbanking.datamodel.account.OBStandingOrder3) 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) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) 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) OBReadStandingOrder3Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder3Data) 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) OBReadStandingOrder3(uk.org.openbanking.datamodel.account.OBReadStandingOrder3) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadStandingOrder3Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder3Data) OBReadStandingOrder3(uk.org.openbanking.datamodel.account.OBReadStandingOrder3) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) FRStandingOrderConverter.toOBStandingOrder3(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder3) OBStandingOrder3(uk.org.openbanking.datamodel.account.OBStandingOrder3)

Example 13 with FRStandingOrder

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder3> 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<OBStandingOrder3> standingOrders = standingOrdersResponse.stream().map(so -> toOBStandingOrder3(so.getStandingOrder())).map(so -> accountDataInternalIdFilter.apply(so)).collect(Collectors.toList());
    int totalPages = standingOrdersResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder3().data(new OBReadStandingOrder3Data().standingOrder(standingOrders)).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) FRStandingOrderConverter.toOBStandingOrder3(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder3) LoggerFactory(org.slf4j.LoggerFactory) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) Controller(org.springframework.stereotype.Controller) OBStandingOrder3(uk.org.openbanking.datamodel.account.OBStandingOrder3) 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) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) 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) OBReadStandingOrder3Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder3Data) 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) OBReadStandingOrder3(uk.org.openbanking.datamodel.account.OBReadStandingOrder3) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadStandingOrder3Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder3Data) OBReadStandingOrder3(uk.org.openbanking.datamodel.account.OBReadStandingOrder3) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) FRStandingOrderConverter.toOBStandingOrder3(com.forgerock.openbanking.common.services.openbanking.converter.account.FRStandingOrderConverter.toOBStandingOrder3) OBStandingOrder3(uk.org.openbanking.datamodel.account.OBStandingOrder3)

Example 14 with FRStandingOrder

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder6> getStandingOrders(int page, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<String> accountIds, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
    log.info("Reading standing orders from account ids {}", accountIds);
    Page<FRStandingOrder> standingOrders = frStandingOrderRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, pageLimitStandingOrders));
    int totalPages = standingOrders.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder6().data(new OBReadStandingOrder6Data().standingOrder(standingOrders.getContent().stream().map(FRStandingOrder::getStandingOrder).map(FRStandingOrderConverter::toOBStandingOrder6).map(so -> accountDataInternalIdFilter.apply(so)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : OBReadStandingOrder6(uk.org.openbanking.datamodel.account.OBReadStandingOrder6) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder) OBReadStandingOrder6Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder6Data)

Example 15 with FRStandingOrder

use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder in project openbanking-aspsp by OpenBankingToolkit.

the class StandingOrdersApiController method getStandingOrders.

@Override
public ResponseEntity<OBReadStandingOrder5> 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 {
    log.info("Reading standing orders from account ids {}", accountIds);
    Page<FRStandingOrder> standingOrders = frStandingOrderRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_STANDING_ORDERS));
    int totalPages = standingOrders.getTotalPages();
    return ResponseEntity.ok(new OBReadStandingOrder5().data(new OBReadStandingOrder5Data().standingOrder(standingOrders.getContent().stream().map(FRStandingOrder::getStandingOrder).map(FRStandingOrderConverter::toOBStandingOrder5).map(so -> accountDataInternalIdFilter.apply(so)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : OBReadStandingOrder5(uk.org.openbanking.datamodel.account.OBReadStandingOrder5) OBReadStandingOrder5Data(uk.org.openbanking.datamodel.account.OBReadStandingOrder5Data) FRStandingOrder(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder)

Aggregations

FRStandingOrder (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRStandingOrder)22 DateTime (org.joda.time.DateTime)13 FRStandingOrderData (com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData)7 List (java.util.List)7 Test (org.junit.Test)7 MoneyService (com.forgerock.openbanking.aspsp.rs.simulator.service.MoneyService)6 PaymentNotificationFacade (com.forgerock.openbanking.aspsp.rs.simulator.service.PaymentNotificationFacade)6 FRStandingOrderRepository (com.forgerock.openbanking.aspsp.rs.store.repository.accounts.standingorders.FRStandingOrderRepository)6 PaginationUtil (com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil)6 FRStandingOrderStatus (com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData.FRStandingOrderStatus)6 FRCreditDebitIndicator (com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRCreditDebitIndicator)6 FRAccountIdentifier (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAccountIdentifier)6 FRAmount (com.forgerock.openbanking.common.model.openbanking.domain.common.FRAmount)6 FRAccount (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount)6 StandingOrderStatus (com.forgerock.openbanking.common.model.openbanking.status.StandingOrderStatus)6 FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList (com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList)6 FrequencyService (com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService)6 AccountStoreService (com.forgerock.openbanking.common.services.store.account.AccountStoreService)6 HTTP_DATE_FORMAT (com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT)6 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)6