use of net.petafuel.styx.core.xs2a.contracts.AISRequest in project styx by petafuel.
the class ConsorsAISTest method testTransactionDetails.
@Test
@Order(5)
public void testTransactionDetails() throws BankRequestFailedException, BankLookupFailedException, BankNotFoundException {
XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setAccountId(ACCOUNT_ID);
xs2AFactoryInput.setTransactionId(TRANSACTION_ID);
xs2AFactoryInput.setConsentId(CONSENT);
AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountTransactionDetails(), xs2AFactoryInput);
Transaction result = standard.getAis().getTransaction(aisRequest);
Assertions.assertNotNull(result);
Assertions.assertNotNull(result.getDebtorAccount());
}
use of net.petafuel.styx.core.xs2a.contracts.AISRequest in project styx by petafuel.
the class BerlinGroupRequestFactoryTest method testAISRequestFactory.
@Test
void testAISRequestFactory() {
BerlinGroupRequestProvider berlinGroupRequestProvider = new BerlinGroupRequestProvider();
AISRequestFactory requestFactory = new AISRequestFactory();
XS2AFactoryInput factoryInput = new XS2AFactoryInput();
AISRequest berlinGroupAccountList = requestFactory.create(berlinGroupRequestProvider.accountList(), factoryInput);
Assertions.assertTrue(berlinGroupAccountList instanceof ReadAccountListRequest);
}
use of net.petafuel.styx.core.xs2a.contracts.AISRequest 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.contracts.AISRequest 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.contracts.AISRequest in project styx by petafuel.
the class AISRequestFactory method create.
@Override
public AISRequest create(Class<? extends AISRequest> providedRequest, XS2AFactoryInput factoryInput) {
try {
Constructor<? extends AISRequest> constructor = providedRequest.getConstructor(Consent.class, String.class, String.class, String.class);
AISRequest aisRequest = constructor.newInstance(factoryInput.getConsent(), factoryInput.getConsentId(), factoryInput.getAccountId(), factoryInput.getTransactionId());
if (factoryInput.getAuthorisationId() != null) {
aisRequest.setAuthorisationId(factoryInput.getAuthorisationId());
}
aisRequest.setPsu(factoryInput.getPsu());
aisRequest.setBookingStatus(factoryInput.getBookingStatus());
aisRequest.setDateFrom(factoryInput.getDateFrom());
aisRequest.setDateTo(factoryInput.getDateTo());
aisRequest.setWithBalance(factoryInput.getWithBalance());
aisRequest.setEntryReferenceFrom(factoryInput.getEntryReferenceFrom());
aisRequest.setDeltaList(factoryInput.getDeltaList());
if (aisRequest instanceof CreateConsentRequest) {
aisRequest.setTppRedirectUri(CallbackProvider.generateCallbackUrl(ServiceRealm.CONSENT, RealmParameter.OK, ThreadContext.get("requestUUID")));
aisRequest.setTppNokRedirectUri(CallbackProvider.generateCallbackUrl(ServiceRealm.PAYMENT, RealmParameter.FAILED, ThreadContext.get("requestUUID")));
}
return aisRequest;
} catch (NoSuchMethodException e) {
throw new XS2AFactoryException(MessageFormat.format("No viable constructor found for request={0} error={1}", providedRequest, e.getMessage()), e);
} catch (IllegalAccessException e) {
throw new XS2AFactoryException(MessageFormat.format("Unable to access constructor for request={0} error={1}", providedRequest, e.getMessage()), e);
} catch (InstantiationException e) {
throw new XS2AFactoryException(MessageFormat.format("Request class is abstract, no viable constructor found for request={0} error={1}", providedRequest, e.getMessage()), e);
} catch (InvocationTargetException e) {
throw new XS2AFactoryException(MessageFormat.format("Request constructor threw an exception for request={0} error={1}", providedRequest, e.getMessage()), e);
} catch (IllegalArgumentException e) {
throw new XS2AFactoryException(MessageFormat.format("The constructor signature was invalid for this Factory for request={0} error={1}", providedRequest, e.getMessage()), e);
}
}
Aggregations