use of net.petafuel.styx.core.xs2a.entities.AccountDetails 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();
}
use of net.petafuel.styx.core.xs2a.entities.AccountDetails in project styx by petafuel.
the class ConsorsAISTest method testAccountList.
@Test
@Order(1)
public void testAccountList() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsentId(CONSENT);
AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountList(), xs2AFactoryInput);
aisRequest.setWithBalance(true);
List<AccountDetails> list = standard.getAis().getAccountList(aisRequest);
Assertions.assertTrue(list.size() >= 1);
}
use of net.petafuel.styx.core.xs2a.entities.AccountDetails in project styx by petafuel.
the class ConsorsAISTest method testAccountDetails.
@Test
@Order(2)
public void testAccountDetails() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setAccountId(ACCOUNT_ID);
xs2AFactoryInput.setConsentId(CONSENT);
xs2AFactoryInput.setWithBalance(true);
AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountDetails(), xs2AFactoryInput);
AccountDetails result = standard.getAis().getAccount(aisRequest);
Assertions.assertNotNull(result);
Assertions.assertNotNull(result.getIban());
}
use of net.petafuel.styx.core.xs2a.entities.AccountDetails in project styx by petafuel.
the class AccountResource method getAccountDetails.
/**
* Returns AccountDetails for a single account
*
* @param accountId the xs2a account id
* @return returns an account object
* @see AccountDetails
*/
@AcceptsPreStepAuth
@GET
@Path("/accounts/{resourceId}")
public Response getAccountDetails(@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 accountDetailsRequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().accountDetails(), xs2AFactoryInput);
accountDetailsRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(accountDetailsRequest, xs2AFactoryInput);
AccountDetails account = getXS2AStandard().getAis().getAccount(accountDetailsRequest);
account.setLinks(new AspspUrlMapper(account.getResourceId()).map(account.getLinks()));
LOG.info("Successfully fetched account details bic={}", getXS2AStandard().getAspsp().getBic());
return Response.status(200).entity(new AccountDetailResponse(account)).build();
}
use of net.petafuel.styx.core.xs2a.entities.AccountDetails in project styx by petafuel.
the class BerlinGroupAIS method getAccount.
@Override
public AccountDetails getAccount(AISRequest request) throws BankRequestFailedException {
this.setUrl(this.url + request.getServicePath());
this.createBody(RequestType.GET);
this.createHeaders(request);
AccountDetails accountDetails;
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create()) {
String responseBody = extractResponseBody(response, 200);
accountDetails = jsonb.fromJson(responseBody, ReadAccountDetailsResponse.class).getAccount();
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
if (accountDetails == null) {
throw new SerializerException("Unable to deserialize account details response body to AccountDetails object");
} else {
return accountDetails;
}
}
Aggregations