Search in sources :

Example 11 with AISRequest

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

Example 12 with AISRequest

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);
}
Also used : BerlinGroupRequestProvider(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.BerlinGroupRequestProvider) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) ReadAccountListRequest(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountListRequest) Test(org.junit.jupiter.api.Test)

Example 13 with AISRequest

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());
}
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 14 with AISRequest

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();
}
Also used : AccountDetailResponse(net.petafuel.styx.api.v1.account.entity.AccountDetailResponse) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) 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 15 with AISRequest

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);
    }
}
Also used : XS2AFactoryException(net.petafuel.styx.core.xs2a.exceptions.XS2AFactoryException) AISRequest(net.petafuel.styx.core.xs2a.contracts.AISRequest) CreateConsentRequest(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.CreateConsentRequest) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)15 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 Test (org.junit.jupiter.api.Test)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 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)5 AccountDetails (net.petafuel.styx.core.xs2a.entities.AccountDetails)4 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)3 Consent (net.petafuel.styx.core.xs2a.entities.Consent)3 BalanceContainer (net.petafuel.styx.core.xs2a.entities.BalanceContainer)2 TransactionContainer (net.petafuel.styx.core.xs2a.entities.TransactionContainer)2 BerlinGroupRequestProvider (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.BerlinGroupRequestProvider)2 CreateConsentRequest (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.CreateConsentRequest)2