Search in sources :

Example 1 with TransactionListResponseAdapter

use of net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter 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 TransactionListResponseAdapter

use of net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter in project styx by petafuel.

the class AccountResourceConsorsTest method testAccountTransactions.

@Test
@Category(IntegrationTest.class)
public void testAccountTransactions() {
    Invocation.Builder invocationBuilder = target("/v1/accounts/" + accountId + "/transactions").queryParam("dateFrom", "2019-01-01").queryParam("bookingStatus", "booked").request();
    invocationBuilder.header("token", aisAccessToken);
    invocationBuilder.header("PSU-BIC", BIC);
    invocationBuilder.header("consentId", consentId);
    Invocation invocation = invocationBuilder.buildGet();
    Response response = invocation.invoke(Response.class);
    Assertions.assertEquals(200, response.getStatus());
    TransactionListResponseAdapter accountDetails = response.readEntity(TransactionListResponseAdapter.class);
    if (accountDetails.getTransactions() != null) {
        accountDetails.getTransactions().forEach(transactionAdapted -> {
            Assertions.assertNotNull(transactionAdapted.getBookingStatus());
            Assertions.assertNotNull(transactionAdapted.getTransactionAmount());
            Assertions.assertNotNull(transactionAdapted.getTransactionAmount().getAmount());
            Assertions.assertNotNull(transactionAdapted.getBookingDate());
            Assertions.assertNotNull(transactionAdapted.getValueDate());
            Assertions.assertNotNull(transactionAdapted.getPurpose());
        });
    }
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) TransactionListResponseAdapter(net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter) ResponseCategory(net.petafuel.styx.api.exception.ResponseCategory) Category(org.junit.experimental.categories.Category) ConsentResourcesConsorsTest(net.petafuel.styx.api.v1.consent.boundary.ConsentResourcesConsorsTest) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test)

Example 3 with TransactionListResponseAdapter

use of net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter in project styx by petafuel.

the class AccountResourceTragoTest method testAccountTransactions.

@Test
@Category(IntegrationTest.class)
public void testAccountTransactions() {
    Invocation.Builder invocationBuilder = target("/v1/accounts/" + accountId + "/transactions").queryParam("dateFrom", "2019-01-01").queryParam("bookingStatus", "booked").request();
    invocationBuilder.header("token", aisAccessToken);
    invocationBuilder.header("PSU-BIC", BIC);
    invocationBuilder.header("consentId", consentId);
    invocationBuilder.header("X-STYX-X-bvpsd2-test-apikey", targobankToken);
    Invocation invocation = invocationBuilder.buildGet();
    Response response = invocation.invoke(Response.class);
    Assertions.assertEquals(200, response.getStatus());
    TransactionListResponseAdapter accountDetails = response.readEntity(TransactionListResponseAdapter.class);
    if (accountDetails.getTransactions() != null) {
        accountDetails.getTransactions().forEach(transactionAdapted -> {
            Assertions.assertNotNull(transactionAdapted.getBookingStatus());
            Assertions.assertNotNull(transactionAdapted.getTransactionAmount());
            Assertions.assertNotNull(transactionAdapted.getTransactionAmount().getAmount());
            Assertions.assertNotNull(transactionAdapted.getBookingDate());
            Assertions.assertNotNull(transactionAdapted.getValueDate());
            Assertions.assertNotNull(transactionAdapted.getPurpose());
        });
    }
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) TransactionListResponseAdapter(net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest) ConsentResourcesTargoTest(net.petafuel.styx.api.v1.consent.boundary.ConsentResourcesTargoTest)

Example 4 with TransactionListResponseAdapter

use of net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter in project styx by petafuel.

the class AccountResourceFiduciaTest method testAccountTransactions.

@Test
@Category(IntegrationTest.class)
public void testAccountTransactions() {
    Invocation.Builder invocationBuilder = target("/v1/accounts/" + accountId + "/transactions").queryParam("dateFrom", "2019-01-01").queryParam("bookingStatus", "booked").request();
    invocationBuilder.header("token", aisAccessToken);
    invocationBuilder.header("PSU-BIC", BIC);
    invocationBuilder.header("consentId", consentId);
    Invocation invocation = invocationBuilder.buildGet();
    Response response = invocation.invoke(Response.class);
    Assertions.assertEquals(200, response.getStatus());
    TransactionListResponseAdapter accountDetails = response.readEntity(TransactionListResponseAdapter.class);
    if (accountDetails.getTransactions() != null) {
        accountDetails.getTransactions().forEach(transactionAdapted -> {
            Assertions.assertNotNull(transactionAdapted.getBookingStatus());
            Assertions.assertNotNull(transactionAdapted.getTransactionAmount());
            Assertions.assertNotNull(transactionAdapted.getTransactionAmount().getAmount());
            Assertions.assertNotNull(transactionAdapted.getBookingDate());
            Assertions.assertNotNull(transactionAdapted.getValueDate());
            Assertions.assertNotNull(transactionAdapted.getPurpose());
        });
    }
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) TransactionListResponseAdapter(net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Aggregations

TransactionListResponseAdapter (net.petafuel.styx.api.v1.account.control.TransactionListResponseAdapter)4 Invocation (javax.ws.rs.client.Invocation)3 Response (javax.ws.rs.core.Response)3 IntegrationTest (net.petafuel.styx.api.IntegrationTest)3 StyxRESTTest (net.petafuel.styx.api.StyxRESTTest)3 AccountDetailResponse (net.petafuel.styx.api.v1.account.entity.AccountDetailResponse)3 Test (org.junit.Test)3 Category (org.junit.experimental.categories.Category)3 ApplicationPath (javax.ws.rs.ApplicationPath)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 ResponseCategory (net.petafuel.styx.api.exception.ResponseCategory)1 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)1 ConsentResourcesConsorsTest (net.petafuel.styx.api.v1.consent.boundary.ConsentResourcesConsorsTest)1 ConsentResourcesTargoTest (net.petafuel.styx.api.v1.consent.boundary.ConsentResourcesTargoTest)1 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)1 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)1 TransactionContainer (net.petafuel.styx.core.xs2a.entities.TransactionContainer)1 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)1