Search in sources :

Example 1 with TransactionContainer

use of net.petafuel.styx.core.xs2a.entities.TransactionContainer in project styx by petafuel.

the class AccountResource method fetchTransactions.

/**
 * This yields the transactions for the specified account. The amount of data varies heavily between banks
 *
 * @param consentId                  consent which has access to the transactions of the specified account
 * @param accountId                  account that containes the requested transactions
 * @param transactionListRequestBean QueryParams bookingStatus, dateFrom and dateTo
 * @return TransactionContainer which holds the transactions/revenues grouped by booking status
 * @throws BankRequestFailedException in case the Request to the Bank failed
 */
@AcceptsPreStepAuth
@GET
@Path("/accounts/{resourceId}/transactions")
public Response fetchTransactions(@NotNull @NotBlank @HeaderParam("consentId") String consentId, @NotNull @NotBlank @PathParam("resourceId") String accountId, @BeanParam @Valid TransactionListRequestBean transactionListRequestBean) throws BankRequestFailedException {
    xs2AFactoryInput.setConsentId(consentId);
    xs2AFactoryInput.setAccountId(accountId);
    xs2AFactoryInput.setBookingStatus(transactionListRequestBean.getBookingStatus());
    xs2AFactoryInput.setDateFrom(transactionListRequestBean.getDateFrom());
    xs2AFactoryInput.setDateTo(transactionListRequestBean.getDateTo());
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    AISRequest readTransactionsRequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().accountTransactionList(), xs2AFactoryInput);
    readTransactionsRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(readTransactionsRequest, xs2AFactoryInput);
    TransactionContainer transactionContainer = getXS2AStandard().getAis().getTransactionsByAccount(readTransactionsRequest);
    LOG.info("Successfully fetched transactions bic={}", getXS2AStandard().getAspsp().getBic());
    TransactionListResponseAdapter transactionListResponseAdapter = new TransactionListResponseAdapter(transactionContainer);
    return Response.status(200).entity(transactionListResponseAdapter).build();
}
Also used : AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) TransactionListResponseAdapter(net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter) AcceptsPreStepAuth(net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth) Path(javax.ws.rs.Path) ApplicationPath(javax.ws.rs.ApplicationPath) GET(javax.ws.rs.GET)

Example 2 with TransactionContainer

use of net.petafuel.styx.core.xs2a.entities.TransactionContainer in project styx by petafuel.

the class Camt052Converter method processReport.

public TransactionContainer processReport(String xmlData) throws SEPAParsingException {
    BankToCustomerAccountReportV02 originalReport = parseReport(xmlData);
    TransactionContainer transactionContainer = new TransactionContainer();
    transactionContainer.setTransactions(new AccountReport());
    transactionContainer.getTransactions().setBooked(new ArrayList<>());
    transactionContainer.getTransactions().setPending(new ArrayList<>());
    transactionContainer.getTransactions().setInformation(new ArrayList<>());
    for (AccountReport11 generalInfoAndTXNs : originalReport.getRpt()) {
        for (ReportEntry2 transactionInfo : generalInfoAndTXNs.getNtry()) {
            convertTransaction(transactionContainer.getTransactions(), transactionInfo);
        }
    }
    return transactionContainer;
}
Also used : TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) BankToCustomerAccountReportV02(net.petafuel.styx.core.xs2a.utils.sepa.camt052.BankToCustomerAccountReportV02) AccountReport11(net.petafuel.styx.core.xs2a.utils.sepa.camt052.AccountReport11) AccountReport(net.petafuel.styx.core.xs2a.entities.AccountReport) ReportEntry2(net.petafuel.styx.core.xs2a.utils.sepa.camt052.ReportEntry2)

Example 3 with TransactionContainer

use of net.petafuel.styx.core.xs2a.entities.TransactionContainer in project styx by petafuel.

the class ConsorsAISTest method testTransactions.

@Test
@Order(4)
public void testTransactions() throws BankLookupFailedException, BankNotFoundException, ParseException, BankRequestFailedException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Date from = format.parse("2019-03-03");
    Date to = new Date();
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setAccountId(ACCOUNT_ID);
    xs2AFactoryInput.setConsentId(CONSENT);
    xs2AFactoryInput.setBookingStatus("booked");
    xs2AFactoryInput.setDateFrom(from);
    xs2AFactoryInput.setDateTo(to);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountTransactionList(), xs2AFactoryInput);
    TransactionContainer result = standard.getAis().getTransactionsByAccount(aisRequest);
    Assertions.assertNotNull(result);
    Assertions.assertNotNull(result.getTransactions());
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) SAD(net.petafuel.styx.core.banklookup.sad.SAD) XS2AFactoryInput(net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput) TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 4 with TransactionContainer

use of net.petafuel.styx.core.xs2a.entities.TransactionContainer in project styx by petafuel.

the class Camt052ParserUnitTest method test.

@Test
void test() throws SEPAParsingException, IOException {
    String camt052Response = IOUtils.toString(getClass().getResourceAsStream("camt052.xml"), Charset.defaultCharset());
    Camt052Converter converter = new Camt052Converter();
    TransactionContainer transactionContainer = converter.processReport(camt052Response);
    Assertions.assertNotNull(transactionContainer);
}
Also used : TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) Camt052Converter(net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter) Test(org.junit.jupiter.api.Test)

Aggregations

TransactionContainer (net.petafuel.styx.core.xs2a.entities.TransactionContainer)4 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)2 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)2 Test (org.junit.jupiter.api.Test)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 ApplicationPath (javax.ws.rs.ApplicationPath)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)1 TransactionListResponseAdapter (net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter)1 XS2AStandard (net.petafuel.styx.core.banklookup.XS2AStandard)1 SAD (net.petafuel.styx.core.banklookup.sad.SAD)1 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)1 AccountReport (net.petafuel.styx.core.xs2a.entities.AccountReport)1 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)1 AccountReport11 (net.petafuel.styx.core.xs2a.utils.sepa.camt052.AccountReport11)1 BankToCustomerAccountReportV02 (net.petafuel.styx.core.xs2a.utils.sepa.camt052.BankToCustomerAccountReportV02)1 ReportEntry2 (net.petafuel.styx.core.xs2a.utils.sepa.camt052.ReportEntry2)1 Camt052Converter (net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter)1