Search in sources :

Example 1 with AccountDetailResponse

use of net.petafuel.styx.api.v1.account.entity.AccountDetailResponse 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)

Aggregations

ApplicationPath (javax.ws.rs.ApplicationPath)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 AcceptsPreStepAuth (net.petafuel.styx.api.filter.authentication.boundary.AcceptsPreStepAuth)1 AspspUrlMapper (net.petafuel.styx.api.util.AspspUrlMapper)1 AccountDetailResponse (net.petafuel.styx.api.v1.account.entity.AccountDetailResponse)1 IOProcessor (net.petafuel.styx.core.ioprocessing.IOProcessor)1 AISRequest (net.petafuel.styx.core.xs2a.contracts.AISRequest)1 AccountDetails (net.petafuel.styx.core.xs2a.entities.AccountDetails)1 AISRequestFactory (net.petafuel.styx.core.xs2a.factory.AISRequestFactory)1