use of uk.org.openbanking.datamodel.account.OBProduct1 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)));
}
Aggregations