use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory in project styx by petafuel.
the class CreateConsentResource method createConsent.
/**
* Creates a consent Resource on the target aspsp xs2a interface
*
* @param postConsentRequest must contain recurringIndicator and the AccountAccess
* @return returns SCA related data for the consent authorisation
* @throws BankRequestFailedException in case something goes wrong while communicating to the ASPSP interface
*/
@RequiresMandatoryHeader
@AcceptsPreStepAuth
@POST
@Path("/consents")
public Response createConsent(@Valid @NotNull POSTConsentRequest postConsentRequest) throws BankRequestFailedException {
Consent requestConsent = new Consent();
requestConsent.setCombinedServiceIndicator(false);
requestConsent.setRecurringIndicator(postConsentRequest.isRecurringIndicator());
requestConsent.setFrequencyPerDay(4);
requestConsent.setAccess(postConsentRequest.getAccess());
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsent(requestConsent);
xs2AFactoryInput.setPsu(getPsu());
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
AISRequest xs2ARequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().consentCreation(), xs2AFactoryInput);
xs2ARequest.getHeaders().putAll(getAdditionalHeaders());
xs2ARequest.setTppRedirectPreferred(getRedirectPreferred());
ioProcessor.modifyRequest(xs2ARequest, xs2AFactoryInput);
Consent consent = getXS2AStandard().getCs().createConsent(xs2ARequest);
POSTConsentResponse postConsentResponse = new POSTConsentResponse();
postConsentResponse.setConsentId(consent.getId());
postConsentResponse.setAspspScaApproach(consent.getSca().getApproach());
postConsentResponse.setPsuMessage(consent.getPsuMessage());
postConsentResponse.setLinks(consent.getLinks());
SCAApproach approach = SCAHandler.decision(consent);
if (approach instanceof OAuth2) {
postConsentResponse.getLinks().getScaOAuth().setUrl(((OAuth2) approach).getAuthoriseLink());
}
AspspUrlMapper aspspUrlMapper = new AspspUrlMapper(consent.getId(), null);
postConsentResponse.setLinks(aspspUrlMapper.map(postConsentResponse.getLinks()));
LOG.info("Created new AIS consent for bic={}", getXS2AStandard().getAspsp().getBic());
return Response.status(Response.Status.CREATED).entity(postConsentResponse).build();
}
use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory in project styx by petafuel.
the class GetConsentResource method getConsentStatus.
/**
* Returns the consent status
*
* @param consentId of the target consent
* @return a GetConsentStatusResponse object
* @throws BankRequestFailedException if something went wrong between the core service and the aspsp
*/
@AcceptsPreStepAuth
@GET
@Path("/consents/{consentId}/status")
public Response getConsentStatus(@NotEmpty @NotBlank @PathParam("consentId") String consentId) throws BankRequestFailedException {
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsentId(consentId);
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
AISRequest request = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().consentStatus(), xs2AFactoryInput);
request.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(request, xs2AFactoryInput);
ConsentStatus state = getXS2AStandard().getCs().getStatus(request);
GetConsentStatusResponse response = new GetConsentStatusResponse(state);
LOG.info("Successfully fetched consent status entity for bic={}, consentId={}", getXS2AStandard().getAspsp().getBic(), consentId);
return Response.status(ResponseConstant.OK).entity(response).build();
}
use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory in project styx by petafuel.
the class GetConsentResource method fetchConsent.
/**
* Returns the consent object with the corresponding accounts
*
* @param consentId of the target consent
* @return a GetConsentResponse object
* @throws BankRequestFailedException if something went wrong between the core service and the aspsp
*/
@AcceptsPreStepAuth
@GET
@Path("/consents/{consentId}")
public Response fetchConsent(@NotEmpty @NotBlank @PathParam("consentId") String consentId) throws BankRequestFailedException {
XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
xs2AFactoryInput.setConsentId(consentId);
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
AISRequest request = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().consentRetrieval(), xs2AFactoryInput);
request.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(request, xs2AFactoryInput);
Consent consent = getXS2AStandard().getCs().getConsent(request);
GetConsentResponse response = new GetConsentResponse(consent);
LOG.info("Successfully fetched consent entity for bic={}, consentId={}", getXS2AStandard().getAspsp().getBic(), consentId);
return Response.status(ResponseConstant.OK).entity(response).build();
}
use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory 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.factory.AISRequestFactory in project styx by petafuel.
the class AccountResource method fetchTransactions.
/**
* This yields the transactions for the specified account. The amount of data varies heavily between banks
*
* @param consentId consent which has access to the transactions of the specified account
* @param accountId account that containes the requested transactions
* @param transactionListRequestBean QueryParams bookingStatus, dateFrom and dateTo
* @return TransactionContainer which holds the transactions/revenues grouped by booking status
* @throws BankRequestFailedException in case the Request to the Bank failed
*/
@AcceptsPreStepAuth
@GET
@Path("/accounts/{resourceId}/transactions")
public Response fetchTransactions(@NotNull @NotBlank @HeaderParam("consentId") String consentId, @NotNull @NotBlank @PathParam("resourceId") String accountId, @BeanParam @Valid TransactionListRequestBean transactionListRequestBean) throws BankRequestFailedException {
xs2AFactoryInput.setConsentId(consentId);
xs2AFactoryInput.setAccountId(accountId);
xs2AFactoryInput.setBookingStatus(transactionListRequestBean.getBookingStatus());
xs2AFactoryInput.setDateFrom(transactionListRequestBean.getDateFrom());
xs2AFactoryInput.setDateTo(transactionListRequestBean.getDateTo());
IOProcessor ioProcessor = new IOProcessor(getXS2AStandard());
ioProcessor.modifyInput(xs2AFactoryInput);
AISRequest readTransactionsRequest = new AISRequestFactory().create(getXS2AStandard().getRequestClassProvider().accountTransactionList(), xs2AFactoryInput);
readTransactionsRequest.getHeaders().putAll(getAdditionalHeaders());
ioProcessor.modifyRequest(readTransactionsRequest, xs2AFactoryInput);
TransactionContainer transactionContainer = getXS2AStandard().getAis().getTransactionsByAccount(readTransactionsRequest);
LOG.info("Successfully fetched transactions bic={}", getXS2AStandard().getAspsp().getBic());
TransactionListResponseAdapter transactionListResponseAdapter = new TransactionListResponseAdapter(transactionContainer);
return Response.status(200).entity(transactionListResponseAdapter).build();
}
Aggregations