Search in sources :

Example 1 with Camt052Converter

use of net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter in project styx by petafuel.

the class Camt052ParserUnitTest method test.

@Test
void test() throws SEPAParsingException, IOException {
    String camt052Response = IOUtils.toString(getClass().getResourceAsStream("camt052.xml"), Charset.defaultCharset());
    Camt052Converter converter = new Camt052Converter();
    TransactionContainer transactionContainer = converter.processReport(camt052Response);
    Assertions.assertNotNull(transactionContainer);
}
Also used : TransactionContainer(net.petafuel.styx.core.xs2a.entities.TransactionContainer) Camt052Converter(net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter) Test(org.junit.jupiter.api.Test)

Example 2 with Camt052Converter

use of net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter 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

Camt052Converter (net.petafuel.styx.core.xs2a.utils.sepa.camt052.control.Camt052Converter)2 Jsonb (javax.json.bind.Jsonb)1 TransactionContainer (net.petafuel.styx.core.xs2a.entities.TransactionContainer)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 ReadTransactionsRequest (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionsRequest)1 Response (okhttp3.Response)1 Test (org.junit.jupiter.api.Test)1