Search in sources :

Example 1 with ReadTransactionsRequest

use of net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionsRequest in project styx by petafuel.

the class STYX06 method apply.

@Override
public boolean apply(XS2AFactoryInput xs2AFactoryInput, XS2ARequest xs2ARequest, XS2AResponse xs2AResponse) throws ImplementerOptionException {
    Boolean optionRequired = ioParser.getOption(IO, IOParser.Option.REQUIRED);
    // return immediately if this options is not required
    if (optionRequired == null || !optionRequired || !(xs2ARequest instanceof ReadTransactionsRequest)) {
        return false;
    }
    ReadTransactionsRequest request = (ReadTransactionsRequest) xs2ARequest;
    request.setXml(true);
    return true;
}
Also used : ReadTransactionsRequest(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionsRequest)

Example 2 with ReadTransactionsRequest

use of net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionsRequest in project styx by petafuel.

the class BerlinGroupAIS method getTransactionsByAccount.

@Override
public TransactionContainer getTransactionsByAccount(AISRequest request) throws BankRequestFailedException {
    this.setUrl(this.url + request.getServicePath() + this.getHttpQueryString(request));
    boolean isXmlRequest = false;
    if (request instanceof ReadTransactionsRequest && ((ReadTransactionsRequest) request).isXml()) {
        isXmlRequest = true;
        request.addHeader(XS2AHeader.ACCEPT, "application/xml");
    }
    this.createBody(RequestType.GET);
    this.createHeaders(request);
    try (Response response = this.execute();
        Jsonb jsonb = JsonbBuilder.create()) {
        String responseBody = extractResponseBody(response, 200);
        if (isXmlRequest) {
            Camt052Converter converter = new Camt052Converter();
            return converter.processReport(responseBody);
        }
        return jsonb.fromJson(responseBody, TransactionContainer.class);
    } catch (Exception e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
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) ReadTransactionsRequest(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionsRequest) SerializerException(net.petafuel.styx.core.xs2a.exceptions.SerializerException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) Camt052Converter(net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter)

Aggregations

ReadTransactionsRequest (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionsRequest)2 Jsonb (javax.json.bind.Jsonb)1 BankRequestFailedException (net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)1 SerializerException (net.petafuel.styx.core.xs2a.exceptions.SerializerException)1 ReadAccountDetailsResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountDetailsResponse)1 ReadAccountListResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountListResponse)1 ReadTransactionDetailsResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionDetailsResponse)1 Camt052Converter (net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter)1 Response (okhttp3.Response)1