Search in sources :

Example 1 with FRProduct

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

the class ProductsApiController method getAccountProduct.

@Override
public ResponseEntity<OBReadProduct1> getAccountProduct(@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 product for account  {} with minimumPermissions {}", accountId, permissions);
    Page<FRProduct> productsResponse = frProductRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_PRODUCTS));
    List<OBProduct1> products = productsResponse.getContent().stream().map(b -> toOBProduct1(b.getProduct())).collect(Collectors.toList());
    int totalPage = productsResponse.getTotalPages();
    return ResponseEntity.ok(new OBReadProduct1().data(new OBReadDataProduct1().product(products)).links(PaginationUtil.generateLinks(httpUrl, page, totalPage)).meta(PaginationUtil.generateMetaData(totalPage)));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) 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) FRProductConverter.toOBProduct1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRProductConverter.toOBProduct1) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) FRProduct(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRProduct) OBReadProduct1(uk.org.openbanking.datamodel.account.OBReadProduct1) PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) Logger(org.slf4j.Logger) OBProduct1(uk.org.openbanking.datamodel.account.OBProduct1) 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) FRProductRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.products.FRProductRepository) List(java.util.List) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) OBReadDataProduct1(uk.org.openbanking.datamodel.account.OBReadDataProduct1) OBReadDataProduct1(uk.org.openbanking.datamodel.account.OBReadDataProduct1) FRProductConverter.toOBProduct1(com.forgerock.openbanking.common.services.openbanking.converter.account.FRProductConverter.toOBProduct1) OBProduct1(uk.org.openbanking.datamodel.account.OBProduct1) OBReadProduct1(uk.org.openbanking.datamodel.account.OBReadProduct1) FRProduct(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRProduct)

Example 2 with FRProduct

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

the class ProductsApiController method getProducts.

@Override
public ResponseEntity<OBReadProduct1> getProducts(@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 products from account ids {}", accountIds);
    Page<FRProduct> frProducts = frProductRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_PRODUCTS));
    int totalPage = frProducts.getTotalPages();
    return ResponseEntity.ok(new OBReadProduct1().data(new OBReadDataProduct1().product(frProducts.getContent().stream().map(p -> toOBProduct1(p.getProduct())).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPage)).meta(PaginationUtil.generateMetaData(totalPage)));
}
Also used : OBReadDataProduct1(uk.org.openbanking.datamodel.account.OBReadDataProduct1) OBReadProduct1(uk.org.openbanking.datamodel.account.OBReadProduct1) FRProduct(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRProduct)

Example 3 with FRProduct

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

the class ProductsApiController method getAccountProduct.

@Override
public ResponseEntity<OBReadProduct2> getAccountProduct(@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, @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 product for account {} with minimumPermissions {}", accountId, permissions);
    Page<FRProduct> products = frProductRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_PRODUCTS));
    int totalPage = products.getTotalPages();
    return ResponseEntity.ok(new OBReadProduct2().data(new OBReadProduct2Data().product(products.getContent().stream().map(p -> accountDataInternalIdFilter.apply(p.getProduct())).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPage)).meta(PaginationUtil.generateMetaData(totalPage)));
}
Also used : OBReadProduct2Data(uk.org.openbanking.datamodel.account.OBReadProduct2Data) OBReadProduct2(uk.org.openbanking.datamodel.account.OBReadProduct2) FRProduct(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRProduct)

Example 4 with FRProduct

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

the class ProductsApiController method getProducts.

@Override
public ResponseEntity<OBReadProduct2> getProducts(@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, @ApiParam(value = "The OB account IDs") @RequestHeader(value = "x-ob-account-ids", required = true) List<String> accountIds, @ApiParam(value = "The OB permissions") @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @ApiParam(value = "The origin http url") @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Reading products from account ids {}", accountIds);
    Page<FRProduct> products = frProductRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_PRODUCTS));
    int totalPage = products.getTotalPages();
    return ResponseEntity.ok(new OBReadProduct2().data(new OBReadProduct2Data().product(products.getContent().stream().map(p -> accountDataInternalIdFilter.apply(p.getProduct())).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPage)).meta(PaginationUtil.generateMetaData(totalPage)));
}
Also used : OBReadProduct2Data(uk.org.openbanking.datamodel.account.OBReadProduct2Data) OBReadProduct2(uk.org.openbanking.datamodel.account.OBReadProduct2) FRProduct(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRProduct)

Aggregations

FRProduct (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRProduct)4 OBReadDataProduct1 (uk.org.openbanking.datamodel.account.OBReadDataProduct1)2 OBReadProduct1 (uk.org.openbanking.datamodel.account.OBReadProduct1)2 OBReadProduct2 (uk.org.openbanking.datamodel.account.OBReadProduct2)2 OBReadProduct2Data (uk.org.openbanking.datamodel.account.OBReadProduct2Data)2 FRProductRepository (com.forgerock.openbanking.aspsp.rs.store.repository.accounts.products.FRProductRepository)1 PaginationUtil (com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil)1 FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList (com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList)1 FRProductConverter.toOBProduct1 (com.forgerock.openbanking.common.services.openbanking.converter.account.FRProductConverter.toOBProduct1)1 HTTP_DATE_FORMAT (com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT)1 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)1 ApiParam (io.swagger.annotations.ApiParam)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 DateTime (org.joda.time.DateTime)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1 Autowired (org.springframework.beans.factory.annotation.Autowired)1 Value (org.springframework.beans.factory.annotation.Value)1 Page (org.springframework.data.domain.Page)1