Search in sources :

Example 1 with OBExternalPermissions1Code

use of uk.org.openbanking.datamodel.account.OBExternalPermissions1Code in project openbanking-aspsp by OpenBankingToolkit.

the class AccountAccessConsentsApiController method createAccountAccessConsents.

@Override
public ResponseEntity<OBReadConsentResponse1> createAccountAccessConsents(@ApiParam(value = "Create an Account Request", required = true) @Valid @RequestBody OBReadConsent1 body, @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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.info("Receveid a new account access consent");
    HttpHeaders additionalHttpHeaders = new HttpHeaders();
    AccountRequestsEndpointWrapper accountRequestEndpoint = RSEndpointWrapperService.accountRequestEndpoint();
    accountRequestEndpoint.authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal);
    if (rsConfiguration.isCustomerInfoEnabled()) {
        log.debug("createAccountAccessConsents() - CustomerInfo consent is enabled");
        @NotNull @Valid @Size(min = 1) List<OBExternalPermissions1Code> permissions = body.getData().getPermissions();
        accountRequestEndpoint.filters(f -> {
            accountAccessConsentPermittedPermissionsFilter.filter(body.getData().getPermissions());
            accountAccessConsentBasicAndDetailPermissionsFilter.filter(body.getData());
            accountAccessConsentPermittedPermissionsFilter.filterByCustomerInfoPermissionRules(body.getData().getPermissions());
        });
    } else {
        accountRequestEndpoint.filters(f -> {
            accountAccessConsentPermittedPermissionsFilter.filter(body.getData().getPermissions());
            accountAccessConsentBasicAndDetailPermissionsFilter.filter(body.getData());
        });
    }
    return accountRequestEndpoint.execute((String aispId) -> {
        additionalHttpHeaders.add("x-ob-aisp_id", aispId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBReadConsentResponse1.class, body);
    });
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) Valid(javax.validation.Valid) Size(javax.validation.constraints.Size) AccountRequestsEndpointWrapper(com.forgerock.openbanking.aspsp.rs.wrappper.endpoints.AccountRequestsEndpointWrapper) NotNull(javax.validation.constraints.NotNull) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code)

Example 2 with OBExternalPermissions1Code

use of uk.org.openbanking.datamodel.account.OBExternalPermissions1Code in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getTransactions.

@Override
public ResponseEntity<OBReadTransaction6> getTransactions(int page, String authorization, DateTime xFapiAuthDate, DateTime fromBookingDateTime, DateTime toBookingDateTime, DateTime firstAvailableDate, DateTime lastAvailableDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<String> accountIds, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
    log.info("Reading transations from account ids {}, fromBookingDate {} toBookingDate {} minimumPermissions {} pageNumber {} ", accountIds, fromBookingDateTime, toBookingDateTime, permissions, page);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> body = FRTransactionRepository.byAccountIdInAndBookingDateTimeBetweenWithPermissions(accountIds, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, pageLimitTransactions, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction6> transactions = body.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction6).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = body.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction6().data(new OBReadDataTransaction6().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : PaginationUtil(com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) PageRequest(org.springframework.data.domain.PageRequest) Controller(org.springframework.stereotype.Controller) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) Page(org.springframework.data.domain.Page) Collectors(java.util.stream.Collectors) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList(com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList) Value(org.springframework.beans.factory.annotation.Value) Slf4j(lombok.extern.slf4j.Slf4j) OBTransaction6(uk.org.openbanking.datamodel.account.OBTransaction6) List(java.util.List) AccountDataInternalIdFilter(com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter) OBExternalPermissions1Code(uk.org.openbanking.datamodel.account.OBExternalPermissions1Code) OBReadTransaction6(uk.org.openbanking.datamodel.account.OBReadTransaction6) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) OBReadDataTransaction6(uk.org.openbanking.datamodel.account.OBReadDataTransaction6) Sort(org.springframework.data.domain.Sort) ResponseEntity(org.springframework.http.ResponseEntity) FRTransactionConverter(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter) OBTransaction6(uk.org.openbanking.datamodel.account.OBTransaction6) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction6(uk.org.openbanking.datamodel.account.OBReadTransaction6) OBReadDataTransaction6(uk.org.openbanking.datamodel.account.OBReadDataTransaction6)

Example 3 with OBExternalPermissions1Code

use of uk.org.openbanking.datamodel.account.OBExternalPermissions1Code in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getAccountStatementTransactions.

@Override
public ResponseEntity<OBReadTransaction2> getAccountStatementTransactions(@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 = "A unique identifier used to identify the statement resource.", required = true) @PathVariable("StatementId") String statementId, @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 UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @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-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
    LOGGER.info("Reading transations from account id {}, statement id {}, fromBookingDate {} toBookingDate {} " + "minimumPermissions {} pageNumber {} ", accountId, statementId, fromBookingDateTime, toBookingDateTime, permissions, page);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = frTransactionRepository.byAccountIdAndStatementIdAndBookingDateTimeBetweenWithPermissions(accountId, statementId, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction2> transactions = response.getContent().stream().map(t -> toOBTransaction2(t.getTransaction())).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction2().data(new OBReadTransaction2Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : OpenBankingConstants(com.forgerock.openbanking.constants.OpenBankingConstants) PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) 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) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) 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) OBReadTransaction2Data(uk.org.openbanking.datamodel.account.OBReadTransaction2Data) OBReadTransaction2(uk.org.openbanking.datamodel.account.OBReadTransaction2) Sort(org.springframework.data.domain.Sort) FRTransactionConverter.toOBTransaction2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter.toOBTransaction2) 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) OBTransaction2(uk.org.openbanking.datamodel.account.OBTransaction2) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction2Data(uk.org.openbanking.datamodel.account.OBReadTransaction2Data) FRTransactionConverter.toOBTransaction2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter.toOBTransaction2) OBTransaction2(uk.org.openbanking.datamodel.account.OBTransaction2) OBReadTransaction2(uk.org.openbanking.datamodel.account.OBReadTransaction2)

Example 4 with OBExternalPermissions1Code

use of uk.org.openbanking.datamodel.account.OBExternalPermissions1Code in project openbanking-aspsp by OpenBankingToolkit.

the class TransactionsApiController method getTransactions.

@Override
public ResponseEntity<OBReadTransaction2> getTransactions(@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 = "The UTC ISO 8601 Date Time to filter transactions FROM  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = FROM_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime fromBookingDateTime, @ApiParam(value = "The UTC ISO 8601 Date Time to filter transactions TO  NB Time component is optional " + "- set to 00:00:00 for just Date.   The parameter must NOT have a timezone set") @RequestParam(value = TO_BOOKING_DATE_TIME, required = false) @DateTimeFormat(pattern = BOOKED_TIME_DATE_FORMAT) DateTime toBookingDateTime, @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-first-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime firstAvailableDate, @RequestHeader(value = "x-ob-last-available-date", required = false) @DateTimeFormat(pattern = AVAILABLE_DATE_FORMAT) DateTime lastAvailableDate, @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 transations from account ids {}, fromBookingDate {} toBookingDate {} " + "minimumPermissions {} pageNumber {} ", accountIds, fromBookingDateTime, toBookingDateTime, permissions, page);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = frTransactionRepository.byAccountIdInAndBookingDateTimeBetweenWithPermissions(accountIds, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_TRANSACTIONS, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction2> transactions = response.getContent().stream().map(t -> toOBTransaction2(t.getTransaction())).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.getTotalPages();
    return ResponseEntity.ok(new OBReadTransaction2().data(new OBReadTransaction2Data().transaction(transactions)).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages, firstAvailableDate, lastAvailableDate)));
}
Also used : OpenBankingConstants(com.forgerock.openbanking.constants.OpenBankingConstants) PathVariable(org.springframework.web.bind.annotation.PathVariable) FROM_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.FROM_BOOKING_DATE_TIME) 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) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) 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) OBReadTransaction2Data(uk.org.openbanking.datamodel.account.OBReadTransaction2Data) OBReadTransaction2(uk.org.openbanking.datamodel.account.OBReadTransaction2) Sort(org.springframework.data.domain.Sort) FRTransactionConverter.toOBTransaction2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter.toOBTransaction2) 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) OBTransaction2(uk.org.openbanking.datamodel.account.OBTransaction2) FRTransactionRepository(com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) TO_BOOKING_DATE_TIME(com.forgerock.openbanking.constants.OpenBankingConstants.ParametersFieldName.TO_BOOKING_DATE_TIME) FRTransaction(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction) OBReadTransaction2Data(uk.org.openbanking.datamodel.account.OBReadTransaction2Data) FRTransactionConverter.toOBTransaction2(com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter.toOBTransaction2) OBTransaction2(uk.org.openbanking.datamodel.account.OBTransaction2) OBReadTransaction2(uk.org.openbanking.datamodel.account.OBReadTransaction2)

Example 5 with OBExternalPermissions1Code

use of uk.org.openbanking.datamodel.account.OBExternalPermissions1Code in project openbanking-aspsp by OpenBankingToolkit.

the class BeneficiariesApiController method getBeneficiaries.

@Override
public ResponseEntity<OBReadBeneficiary1> getBeneficiaries(@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("Beneficaries from account ids {}", accountIds);
    Page<FRBeneficiary> beneficiariesResponse = frBeneficiaryRepository.byAccountIdInWithPermissions(accountIds, 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)

Aggregations

OBExternalPermissions1Code (uk.org.openbanking.datamodel.account.OBExternalPermissions1Code)33 PaginationUtil (com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil)31 FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList (com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList)31 List (java.util.List)31 DateTime (org.joda.time.DateTime)31 ResponseEntity (org.springframework.http.ResponseEntity)31 Controller (org.springframework.stereotype.Controller)31 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)30 Collectors (java.util.stream.Collectors)30 Value (org.springframework.beans.factory.annotation.Value)28 Page (org.springframework.data.domain.Page)28 PageRequest (org.springframework.data.domain.PageRequest)28 DateTimeFormat (org.springframework.format.annotation.DateTimeFormat)26 PathVariable (org.springframework.web.bind.annotation.PathVariable)26 RequestHeader (org.springframework.web.bind.annotation.RequestHeader)26 RequestParam (org.springframework.web.bind.annotation.RequestParam)26 ApiParam (io.swagger.annotations.ApiParam)25 Autowired (org.springframework.beans.factory.annotation.Autowired)25 Logger (org.slf4j.Logger)23 LoggerFactory (org.slf4j.LoggerFactory)23