Search in sources :

Example 1 with OBReadBeneficiary1

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

the class ScheduledPaymentsApiController method getScheduledPayments.

@Override
public ResponseEntity<OBReadScheduledPayment1> getScheduledPayments(@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") String 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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    return RSEndpointWrapperService.<OBReadBeneficiary1>accountAndTransactionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).page(page).minimumPermissions(FRExternalPermissionsCode.READSCHEDULEDPAYMENTSBASIC, FRExternalPermissionsCode.READSCHEDULEDPAYMENTSDETAIL).execute((accountRequest, permissions, pageNumber) -> {
        LOGGER.info("Scheduled payments get with id {}", accountRequest.getAccountIds());
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.addAll("x-ob-account-ids", accountRequest.getAccountIds());
        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, OBReadScheduledPayment1.class);
    });
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) OBReadBeneficiary1(uk.org.openbanking.datamodel.account.OBReadBeneficiary1) FRExternalPermissionsCode(com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)

Example 2 with OBReadBeneficiary1

use of uk.org.openbanking.datamodel.account.OBReadBeneficiary1 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") String 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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    return RSEndpointWrapperService.<OBReadBeneficiary1>accountAndTransactionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).page(page).minimumPermissions(FRExternalPermissionsCode.READBENEFICIARIESBASIC, FRExternalPermissionsCode.READBENEFICIARIESDETAIL).execute((accountRequest, permissions, pageNumber) -> {
        LOGGER.info("Beneficaries get with id {}", accountRequest.getAccountIds());
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.addAll("x-ob-account-ids", accountRequest.getAccountIds());
        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, OBReadBeneficiary2.class);
    });
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) OBReadBeneficiary1(uk.org.openbanking.datamodel.account.OBReadBeneficiary1) FRExternalPermissionsCode(com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)

Example 3 with OBReadBeneficiary1

use of uk.org.openbanking.datamodel.account.OBReadBeneficiary1 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)

Example 4 with OBReadBeneficiary1

use of uk.org.openbanking.datamodel.account.OBReadBeneficiary1 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") String 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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    return RSEndpointWrapperService.<OBReadBeneficiary1>accountAndTransactionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).page(page).minimumPermissions(FRExternalPermissionsCode.READBENEFICIARIESBASIC, FRExternalPermissionsCode.READBENEFICIARIESDETAIL).execute((accountRequest, permissions, pageNumber) -> {
        LOGGER.info("Beneficaries get with id {}", accountRequest.getAccountIds());
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.addAll("x-ob-account-ids", accountRequest.getAccountIds());
        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, OBReadBeneficiary1.class);
    });
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) OBReadBeneficiary1(uk.org.openbanking.datamodel.account.OBReadBeneficiary1) FRExternalPermissionsCode(com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)

Example 5 with OBReadBeneficiary1

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

the class OffersApiController method getOffers.

@Override
public ResponseEntity<OBReadOffer1> getOffers(@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") String 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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    return RSEndpointWrapperService.<OBReadBeneficiary1>accountAndTransactionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).page(page).minimumPermissions(FRExternalPermissionsCode.READOFFERS).execute((accountRequest, permissions, pageNumber) -> {
        LOGGER.info("Offers get with id {}", accountRequest.getAccountIds());
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.addAll("x-ob-account-ids", accountRequest.getAccountIds());
        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, OBReadOffer1.class);
    });
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ServletServerHttpRequest(org.springframework.http.server.ServletServerHttpRequest) OBReadBeneficiary1(uk.org.openbanking.datamodel.account.OBReadBeneficiary1) FRExternalPermissionsCode(com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)

Aggregations

OBReadBeneficiary1 (uk.org.openbanking.datamodel.account.OBReadBeneficiary1)6 FRExternalPermissionsCode (com.forgerock.openbanking.common.model.openbanking.domain.account.common.FRExternalPermissionsCode)4 HttpHeaders (org.springframework.http.HttpHeaders)4 ServletServerHttpRequest (org.springframework.http.server.ServletServerHttpRequest)4 FRBeneficiaryRepository (com.forgerock.openbanking.aspsp.rs.store.repository.accounts.beneficiaries.FRBeneficiaryRepository)2 PaginationUtil (com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil)2 FRBeneficiary (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRBeneficiary)2 FRAccountBeneficiaryConverter.toOBBeneficiary1 (com.forgerock.openbanking.common.services.openbanking.converter.account.FRAccountBeneficiaryConverter.toOBBeneficiary1)2 FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList (com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList)2 HTTP_DATE_FORMAT (com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT)2 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)2 ApiParam (io.swagger.annotations.ApiParam)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 DateTime (org.joda.time.DateTime)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Value (org.springframework.beans.factory.annotation.Value)2 Page (org.springframework.data.domain.Page)2