Search in sources :

Example 1 with OBReadBeneficiary2

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

the class PartyApiController method getAccountParty.

@Override
public ResponseEntity<OBReadParty1> getAccountParty(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @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 {
    return RSEndpointWrapperService.<OBReadBeneficiary2>accountAndTransactionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).accountId(accountId).principal(principal).minimumPermissions(FRExternalPermissionsCode.READPARTY).execute((accountRequest, permissions, pageNumber) -> {
        LOGGER.info("Read party for account {} with minimumPermissions {}", accountId, permissions);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.addAll("x-ob-permissions", permissions.stream().map(FRExternalPermissionsCode::name).collect(Collectors.toList()));
        additionalHttpHeaders.add("x-ob-url", new ServletServerHttpRequest(request).getURI().toString());
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, OBReadParty1.class);
    });
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) OBReadBeneficiary2(uk.org.openbanking.datamodel.account.OBReadBeneficiary2) FRExternalPermissionsCode(com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)

Example 2 with OBReadBeneficiary2

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

the class BeneficiariesApiController method getAccountBeneficiaries.

@Override
public ResponseEntity<OBReadBeneficiary2> getAccountBeneficiaries(@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 beneficiaries for account {} with minimumPermissions {}", accountId, permissions);
    Page<FRBeneficiary> beneficiaries = frBeneficiaryRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_BENEFICIARIES));
    int totalPages = beneficiaries.getTotalPages();
    return ResponseEntity.ok(new OBReadBeneficiary2().data(new OBReadBeneficiary2Data().beneficiary(beneficiaries.getContent().stream().map(FRBeneficiary::getBeneficiary).map(FRAccountBeneficiaryConverter::toOBBeneficiary2).map(b -> accountDataInternalIdFilter.apply(b)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : OBReadBeneficiary2Data(uk.org.openbanking.datamodel.account.OBReadBeneficiary2Data) OBReadBeneficiary2(uk.org.openbanking.datamodel.account.OBReadBeneficiary2) FRBeneficiary(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRBeneficiary)

Example 3 with OBReadBeneficiary2

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

the class BeneficiariesApiController method getBeneficiaries.

@Override
public ResponseEntity<OBReadBeneficiary2> 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> beneficiaries = frBeneficiaryRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_BENEFICIARIES));
    int totalPages = beneficiaries.getTotalPages();
    return ResponseEntity.ok(new OBReadBeneficiary2().data(new OBReadBeneficiary2Data().beneficiary(beneficiaries.getContent().stream().map(FRBeneficiary::getBeneficiary).map(FRAccountBeneficiaryConverter::toOBBeneficiary2).map(b -> accountDataInternalIdFilter.apply(b)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Also used : OBReadBeneficiary2Data(uk.org.openbanking.datamodel.account.OBReadBeneficiary2Data) OBReadBeneficiary2(uk.org.openbanking.datamodel.account.OBReadBeneficiary2) FRBeneficiary(com.forgerock.openbanking.common.model.openbanking.persistence.account.FRBeneficiary)

Aggregations

OBReadBeneficiary2 (uk.org.openbanking.datamodel.account.OBReadBeneficiary2)3 FRBeneficiary (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRBeneficiary)2 OBReadBeneficiary2Data (uk.org.openbanking.datamodel.account.OBReadBeneficiary2Data)2 FRExternalPermissionsCode (com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)1 HttpHeaders (org.springframework.http.HttpHeaders)1 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)1