Search in sources :

Example 6 with AISRequestFactory

use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory 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();
}
Also used : AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) AccountListResponseAdapter(net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter) AspspUrlMapper(net.petafuel.styx.api.util.AspspUrlMapper) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) IOProcessor(net.petafuel.styx.core.ioprocessing.IOProcessor) AccountDetails(net.petafuel.styx.core.xs2a.entities.AccountDetails) 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 7 with AISRequestFactory

use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory in project styx by petafuel.

the class ConsorsAISTest method testTransactions.

@Test
@Order(4)
public void testTransactions() throws BankLookupFailedException, BankNotFoundException, ParseException, BankRequestFailedException {
    XS2AStandard standard = (new SAD()).getBankByBIC(BIC, true);
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    Date from = format.parse("2019-03-03");
    Date to = new Date();
    XS2AFactoryInput xs2AFactoryInput = new XS2AFactoryInput();
    xs2AFactoryInput.setAccountId(ACCOUNT_ID);
    xs2AFactoryInput.setConsentId(CONSENT);
    xs2AFactoryInput.setBookingStatus("booked");
    xs2AFactoryInput.setDateFrom(from);
    xs2AFactoryInput.setDateTo(to);
    AISRequest aisRequest = new AISRequestFactory().create(standard.getRequestClassProvider().accountTransactionList(), xs2AFactoryInput);
    TransactionContainer result = standard.getAis().getTransactionsByAccount(aisRequest);
    Assertions.assertNotNull(result);
    Assertions.assertNotNull(result.getTransactions());
}
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) TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) AISRequestFactory(net.petafuel.styx.core.xs2a.factory.AISRequestFactory) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 8 with AISRequestFactory

use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory 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 9 with AISRequestFactory

use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory 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);
}
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) AccountDetails(net.petafuel.styx.core.xs2a.entities.AccountDetails) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Example 10 with AISRequestFactory

use of net.petafuel.styx.core.xs2a.factory.AISRequestFactory 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());
}
Also used : XS2AStandard(net.petafuel.styx.core.banklookup.XS2AStandard) Transaction(net.petafuel.styx.core.xs2a.entities.Transaction) 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) TestMethodOrder(org.junit.jupiter.api.TestMethodOrder) Order(org.junit.jupiter.api.Order) Test(org.junit.jupiter.api.Test)

Aggregations

AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)12 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)12 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)8 ApplicationPath (javax.ws.rs.ApplicationPath)7 Path (javax.ws.rs.Path)7 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)7 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)7 GET (javax.ws.rs.GET)6 XS2AStandard (net.petafuel.styx.core.banklookup.XS2AStandard)5 SAD (net.petafuel.styx.core.banklookup.sad.SAD)5 Order (org.junit.jupiter.api.Order)5 Test (org.junit.jupiter.api.Test)5 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)5 AccountDetails (net.petafuel.styx.core.xs2a.entities.AccountDetails)4 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)3 BalanceContainer (net.petafuel.styx.core.xs2a.entities.BalanceContainer)2 Consent (net.petafuel.styx.core.xs2a.entities.Consent)2 TransactionContainer (net.petafuel.styx.core.xs2a.entities.TransactionContainer)2 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1