Search in sources :

Example 1 with BalanceContainer

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

the class AccountResource method fetchBalances.

/**
 * Fetch a list of balances(mandatory) with an optional linked account
 *
 * @param accountId the xs2a account id
 * @param consentId a consent with status VALID
 * @return returns a list of balances, optionally a linked account
 */
@AcceptsPreStepAuth
@GET
@Path("/accounts/{resourceId}/balances")
public Response fetchBalances(@NotNull @NotBlank @HeaderParam("consentId") String consentId, @NotNull @NotBlank @PathParam("resourceId") String accountId) throws BankRequestFailedException {
    xs2AFactoryInput.setConsentId(consentId);
    xs2AFactoryInput.setAccountId(accountId);
    IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
    ioProcessor.modifyInput(xs2AFactoryInput);
    AISRequest readBalancesRequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().accountBalances(), xs2AFactoryInput);
    readBalancesRequest.getHeaders().putAll(getAdditionalHeaders());
    ioProcessor.modifyRequest(readBalancesRequest, xs2AFactoryInput);
    BalanceContainer balances = getXS2AStandard().getAis().getBalancesByAccount(readBalancesRequest);
    LOG.info("Successfully fetched balances bic={}", getXS2AStandard().getAspsp().getBic());
    return Response.status(200).entity(balances).build();
}
Also used : AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) BalanceContainer(net.petafuel.styx.core.xs2a.entities.BalanceContainer) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) 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 BalanceContainer

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

the class AccountResourceTragoTest method testAccountBalances.

@Test
@Category(IntegrationTest.class)
public void testAccountBalances() {
    Invocation.Builder invocationBuilder = target("/v1/accounts/" + accountId + "/balances").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());
    BalanceContainer accountDetails = response.readEntity(BalanceContainer.class);
    if (accountDetails.getAccount() != null) {
        Assertions.assertNotNull(accountDetails.getAccount().getIban());
    }
    accountDetails.getBalances().forEach(balance -> {
        Assertions.assertNotNull(balance.getBalanceAmount().getAmount());
        Assertions.assertNotNull(balance.getBalanceAmount().getCurrency());
        Assertions.assertNotNull(balance.getBalanceType());
    });
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) BalanceContainer(net.petafuel.styx.core.xs2a.entities.BalanceContainer) 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 3 with BalanceContainer

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

the class ConsorsAISTest method testBalances.

@Test
@Order(3)
public void testBalances() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setAccountId(ACCOUNT_ID);
    xs2AFactoryInput.setConsentId(CONSENT);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountBalances(), xs2AFactoryInput);
    BalanceContainer result = standard.getAis().getBalancesByAccount(aisRequest);
    Assertions.assertNotNull(result);
    Assertions.assertTrue(result.getBalances().size() >= 1);
}
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) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) BalanceContainer(net.petafuel.styx.core.xs2a.entities.BalanceContainer) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 4 with BalanceContainer

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

the class AccountResourceConsorsTest method testAccountBalances.

@Test
@Category(IntegrationTest.class)
public void testAccountBalances() {
    Invocation.Builder invocationBuilder = target("/v1/accounts/" + accountId + "/balances").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());
    BalanceContainer accountDetails = response.readEntity(BalanceContainer.class);
    if (accountDetails.getAccount() != null) {
        Assertions.assertNotNull(accountDetails.getAccount().getIban());
    }
    accountDetails.getBalances().forEach(balance -> {
        Assertions.assertNotNull(balance.getBalanceAmount().getAmount());
        Assertions.assertNotNull(balance.getBalanceAmount().getCurrency());
        Assertions.assertNotNull(balance.getBalanceType());
        Assertions.assertNotNull(balance.getBalanceType());
    });
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) BalanceContainer(net.petafuel.styx.core.xs2a.entities.BalanceContainer) 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 5 with BalanceContainer

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

the class AccountResourceFiduciaTest method testAccountBalances.

@Test
@Category(IntegrationTest.class)
public void testAccountBalances() {
    Invocation.Builder invocationBuilder = target("/v1/accounts/" + accountId + "/balances").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());
    BalanceContainer accountDetails = response.readEntity(BalanceContainer.class);
    if (accountDetails.getAccount() != null) {
        Assertions.assertNotNull(accountDetails.getAccount().getIban());
    }
    accountDetails.getBalances().forEach(balance -> {
        Assertions.assertNotNull(balance.getBalanceAmount().getAmount());
        Assertions.assertNotNull(balance.getBalanceAmount().getCurrency());
        Assertions.assertNotNull(balance.getBalanceType());
    });
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) Response(javax.ws.rs.core.Response) Invocation(javax.ws.rs.client.Invocation) BalanceContainer(net.petafuel.styx.core.xs2a.entities.BalanceContainer) Category(org.junit.experimental.categories.Category) IntegrationTest(net.petafuel.styx.api.IntegrationTest) Test(org.junit.Test) StyxRESTTest(net.petafuel.styx.api.StyxRESTTest)

Aggregations

BalanceContainer (net.petafuel.styx.core.xs2a.entities.BalanceContainer)5 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 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)2 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)2 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 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