Search in sources :

Example 1 with AccountDetails

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

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);
}
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 3 with AccountDetails

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

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

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;
    }
}
Also used : ReadAccountDetailsResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountDetailsResponse) ReadTransactionDetailsResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionDetailsResponse) Response(okhttp3.Response) ReadAccountListResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountListResponse) Jsonb(javax.json.bind.Jsonb) SerializerException(net.petafuel.styx.core.xs2a.exceptions.SerializerException) SerializerException(net.petafuel.styx.core.xs2a.exceptions.SerializerException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) AccountDetails(net.petafuel.styx.core.xs2a.entities.AccountDetails)

Aggregations

AccountDetails (net.petafuel.styx.core.xs2a.entities.AccountDetails)5 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)4 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)4 ApplicationPath (javax.ws.rs.ApplicationPath)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)2 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)2 XS2AStandard (net.petafuel.styx.core.banklookup.XS2AStandard)2 SAD (net.petafuel.styx.core.banklookup.sad.SAD)2 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)2 XS2AFactoryInput (net.petafuel.styx.core.xs2a.factory.XS2AFactoryInput)2 Order (org.junit.jupiter.api.Order)2 Test (org.junit.jupiter.api.Test)2 TestMethodOrder (org.junit.jupiter.api.TestMethodOrder)2 Jsonb (javax.json.bind.Jsonb)1 AccountListResponseAdapter (net.petafuel.styx.api.v1.account.control.AccountListResponseAdapter)1 AccountDetailResponse (net.petafuel.styx.api.v1.account.entity.AccountDetailResponse)1 BankRequestFailedException (net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)1 SerializerException (net.petafuel.styx.core.xs2a.exceptions.SerializerException)1