Search in sources :

Example 1 with OBReadTransaction6

use of uk.org.openbanking.datamodel.account.OBReadTransaction6 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 2 with OBReadTransaction6

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

the class TransactionsApiController method getAccountTransactions.

@Override
public ResponseEntity<OBReadTransaction6> getAccountTransactions(String accountId, int page, String authorization, DateTime xFapiAuthDate, DateTime fromBookingDateTime, DateTime toBookingDateTime, DateTime firstAvailableDate, DateTime lastAvailableDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
    log.info("Read transactions for account  {} with minimumPermissions {}", accountId, permissions);
    log.debug("transactionStore request transactionFrom {} transactionTo {} ", fromBookingDateTime, toBookingDateTime);
    if (toBookingDateTime == null) {
        toBookingDateTime = DateTime.now();
    }
    if (fromBookingDateTime == null) {
        fromBookingDateTime = toBookingDateTime.minusYears(100);
    }
    Page<FRTransaction> response = FRTransactionRepository.byAccountIdAndBookingDateTimeBetweenWithPermissions(accountId, fromBookingDateTime, toBookingDateTime, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, pageLimitTransactions, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction6> transactions = response.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction6).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.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 OBReadTransaction6

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

the class TransactionsApiController method getAccountStatementTransactions.

@Override
public ResponseEntity<OBReadTransaction6> getAccountStatementTransactions(String statementId, String accountId, int page, String authorization, DateTime xFapiAuthDate, DateTime fromBookingDateTime, DateTime toBookingDateTime, DateTime firstAvailableDate, DateTime lastAvailableDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, List<OBExternalPermissions1Code> permissions, String httpUrl) throws OBErrorResponseException {
    log.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, pageLimitTransactions, Sort.Direction.ASC, "bookingDateTime"));
    List<OBTransaction6> transactions = response.getContent().stream().map(FRTransaction::getTransaction).map(FRTransactionConverter::toOBTransaction6).map(t -> accountDataInternalIdFilter.apply(t)).collect(Collectors.toList());
    // Package the answer
    int totalPages = response.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)

Aggregations

FRTransactionRepository (com.forgerock.openbanking.aspsp.rs.store.repository.accounts.transactions.FRTransactionRepository)3 AccountDataInternalIdFilter (com.forgerock.openbanking.aspsp.rs.store.utils.AccountDataInternalIdFilter)3 PaginationUtil (com.forgerock.openbanking.aspsp.rs.store.utils.PaginationUtil)3 FRTransaction (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRTransaction)3 FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList (com.forgerock.openbanking.common.services.openbanking.converter.account.FRExternalPermissionsCodeConverter.toFRExternalPermissionsCodeList)3 FRTransactionConverter (com.forgerock.openbanking.common.services.openbanking.converter.account.FRTransactionConverter)3 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Slf4j (lombok.extern.slf4j.Slf4j)3 DateTime (org.joda.time.DateTime)3 Value (org.springframework.beans.factory.annotation.Value)3 Page (org.springframework.data.domain.Page)3 PageRequest (org.springframework.data.domain.PageRequest)3 Sort (org.springframework.data.domain.Sort)3 ResponseEntity (org.springframework.http.ResponseEntity)3 Controller (org.springframework.stereotype.Controller)3 OBExternalPermissions1Code (uk.org.openbanking.datamodel.account.OBExternalPermissions1Code)3 OBReadDataTransaction6 (uk.org.openbanking.datamodel.account.OBReadDataTransaction6)3 OBReadTransaction6 (uk.org.openbanking.datamodel.account.OBReadTransaction6)3