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();
}
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());
});
}
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);
}
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());
});
}
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());
});
}
Aggregations