Search in sources :

Example 1 with AccountListResponseAdapter

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

the class AccountResource method processAccountList.

/**
 * Returns a List of Accounts
 *
 * @param consentId consentId with access to the requested account list
 * @return returns an account list
 * @see AccountListResponseAdapter
 */
@AcceptsPreStepAuth
@GET
@Path("/accounts")
public Response processAccountList(@NotNull @NotBlank @HeaderParam("consentId") String consentId) throws BankRequestFailedException {
    xs2AFactoryInput.setConsentId(consentId);
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    AISRequest accountListRequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().accountList(), xs2AFactoryInput);
    accountListRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(accountListRequest, xs2AFactoryInput);
    List<AccountDetails> accountList = getXS2AStandard().getAis().getAccountList(accountListRequest);
    accountList.forEach(accountDetails -> accountDetails.setLinks(new AspspUrlMapper(accountDetails.getResourceId()).map(accountDetails.getLinks())));
    LOG.info("Successfully fetched account list for bic={}", getXS2AStandard().getAspsp().getBic());
    return Response.status(200).entity(new AccountListResponseAdapter(accountList)).build();
}
Also used : AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) AccountListResponseAdapter(net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter) AspspUrlMapper(net.petafuel.styx.api.util.AspspUrlMapper) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AccountDetails(net.petafuel.styx.core.xs2a.entities.AccountDetails) 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 AccountListResponseAdapter

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

the class AccountResourceConsorsTest method A_testAccountList.

@Test
@Category(IntegrationTest.class)
public void A_testAccountList() {
    Invocation.Builder invocationBuilder = target("/v1/accounts").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());
    AccountListResponseAdapter accountListResponseAdapter = response.readEntity(AccountListResponseAdapter.class);
    Assertions.assertNotNull(accountListResponseAdapter.getAccounts());
    Assertions.assertNotNull(accountListResponseAdapter.getAccounts().get(0).getIban());
    accountId = accountListResponseAdapter.getAccounts().get(0).getResourceId();
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) AccountListResponseAdapter(net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter) 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 AccountListResponseAdapter

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

the class AccountResourceFiduciaTest method A_testAccountList.

@Test
@Category(IntegrationTest.class)
public void A_testAccountList() {
    Invocation.Builder invocationBuilder = target("/v1/accounts").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());
    AccountListResponseAdapter accountListResponseAdapter = response.readEntity(AccountListResponseAdapter.class);
    Assertions.assertNotNull(accountListResponseAdapter.getAccounts());
    Assertions.assertNotNull(accountListResponseAdapter.getAccounts().get(0).getIban());
    accountId = accountListResponseAdapter.getAccounts().get(0).getResourceId();
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) AccountListResponseAdapter(net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Example 4 with AccountListResponseAdapter

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

the class AccountResourceTragoTest method A_testAccountList.

@Test
@Category(IntegrationTest.class)
public void A_testAccountList() {
    Invocation.Builder invocationBuilder = target("/v1/accounts").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());
    AccountListResponseAdapter accountListResponseAdapter = response.readEntity(AccountListResponseAdapter.class);
    Assertions.assertNotNull(accountListResponseAdapter.getAccounts());
    Assertions.assertNotNull(accountListResponseAdapter.getAccounts().get(0).getIban());
    accountId = accountListResponseAdapter.getAccounts().get(0).getResourceId();
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) AccountListResponseAdapter(net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter) 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)

Aggregations

AccountListResponseAdapter (net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter)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 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)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 AccountDetails (net.petafuel.styx.core.xs2a.entities.AccountDetails)1 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)1