Search in sources :

Example 1 with BankRequestFailedException

use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.

the class BasicAuthorisationService method startAuthorisation.

protected SCA startAuthorisation(StartAuthorisationRequest request) throws BankRequestFailedException {
    this.setUrl(this.url + request.getServicePath());
    this.createBody(RequestType.POST, JSON, request);
    this.createHeaders(request);
    try (Response response = this.execute();
        Jsonb jsonb = JsonbBuilder.create()) {
        String responseBody = extractResponseBody(response, 201);
        SCA sca = jsonb.fromJson(responseBody, SCA.class);
        SCAUtils.parseSCAApproach(sca, response);
        return sca;
    } catch (Exception e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : GetAuthorisationResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetAuthorisationResponse) GetSCAStatusResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetSCAStatusResponse) Response(okhttp3.Response) SCA(net.petafuel.styx.core.xs2a.entities.SCA) Jsonb(javax.json.bind.Jsonb) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Example 2 with BankRequestFailedException

use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.

the class BasicAuthorisationService method getSCAStatus.

protected SCA.Status getSCAStatus(GetSCAStatusRequest xs2ARequest) throws BankRequestFailedException {
    this.setUrl(this.url + xs2ARequest.getServicePath());
    this.createBody(RequestType.GET);
    this.createHeaders(xs2ARequest);
    try (Response response = this.execute();
        Jsonb jsonb = JsonbBuilder.create()) {
        String responseBody = extractResponseBody(response, 200);
        GetSCAStatusResponse getSCAStatusResponse = jsonb.fromJson(responseBody, GetSCAStatusResponse.class);
        return getSCAStatusResponse.getScaStatus();
    } catch (Exception e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : GetAuthorisationResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetAuthorisationResponse) GetSCAStatusResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetSCAStatusResponse) Response(okhttp3.Response) Jsonb(javax.json.bind.Jsonb) GetSCAStatusResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetSCAStatusResponse) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Example 3 with BankRequestFailedException

use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.

the class BasicAuthorisationService method selectAuthenticationMethod.

protected SCA selectAuthenticationMethod(SelectAuthenticationMethodRequest selectAuthenticationMethodRequest) throws BankRequestFailedException {
    this.setUrl(this.url + selectAuthenticationMethodRequest.getServicePath());
    this.createBody(RequestType.PUT, JSON, selectAuthenticationMethodRequest);
    this.createHeaders(selectAuthenticationMethodRequest);
    try (Response response = this.execute();
        Jsonb jsonb = JsonbBuilder.create()) {
        String responseBody = extractResponseBody(response, 200);
        SCA sca = jsonb.fromJson(responseBody, SCA.class);
        SCAUtils.parseSCAApproach(sca, response);
        return sca;
    } catch (Exception e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : GetAuthorisationResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetAuthorisationResponse) GetSCAStatusResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetSCAStatusResponse) Response(okhttp3.Response) SCA(net.petafuel.styx.core.xs2a.entities.SCA) Jsonb(javax.json.bind.Jsonb) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Example 4 with BankRequestFailedException

use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.

the class BasicAuthorisationService method updatePSUIdentification.

protected SCA updatePSUIdentification(UpdatePSUIdentificationRequest updatePSUIdentificationRequest) throws BankRequestFailedException {
    this.setUrl(this.url + updatePSUIdentificationRequest.getServicePath());
    this.createBody(RequestType.PUT, JSON, updatePSUIdentificationRequest);
    this.createHeaders(updatePSUIdentificationRequest);
    try (Response response = this.execute();
        Jsonb jsonb = JsonbBuilder.create()) {
        String responseBody = extractResponseBody(response, 200);
        SCA sca = jsonb.fromJson(responseBody, SCA.class);
        SCAUtils.parseSCAApproach(sca, response);
        return sca;
    } catch (Exception e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : GetAuthorisationResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetAuthorisationResponse) GetSCAStatusResponse(net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetSCAStatusResponse) Response(okhttp3.Response) SCA(net.petafuel.styx.core.xs2a.entities.SCA) Jsonb(javax.json.bind.Jsonb) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Example 5 with BankRequestFailedException

use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.

the class BerlinGroupCS method deleteConsent.

@Override
public Consent deleteConsent(AISRequest consentDeleteRequest) throws BankRequestFailedException {
    this.setUrl(this.url + consentDeleteRequest.getServicePath());
    this.createBody(RequestType.DELETE);
    this.createHeaders(consentDeleteRequest);
    try (Response response = this.execute()) {
        extractResponseBody(response, 204, false);
        Consent consent = new Consent();
        consent.setId(consentDeleteRequest.getConsentId());
        return new PersistentConsent().updateState(consent, ConsentStatus.TERMINATED_BY_TPP);
    } catch (IOException e) {
        throw new BankRequestFailedException(e.getMessage(), e);
    }
}
Also used : Response(okhttp3.Response) Consent(net.petafuel.styx.core.xs2a.entities.Consent) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) IOException(java.io.IOException) PersistentConsent(net.petafuel.styx.core.persistence.layers.PersistentConsent) BankRequestFailedException(net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)

Aggregations

BankRequestFailedException (net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException)28 Jsonb (javax.json.bind.Jsonb)22 Response (okhttp3.Response)22 SerializerException (net.petafuel.styx.core.xs2a.exceptions.SerializerException)8 IOException (java.io.IOException)7 SCA (net.petafuel.styx.core.xs2a.entities.SCA)7 GetAuthorisationResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetAuthorisationResponse)7 GetSCAStatusResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_3.http.GetSCAStatusResponse)7 PersistentConsent (net.petafuel.styx.core.persistence.layers.PersistentConsent)5 Consent (net.petafuel.styx.core.xs2a.entities.Consent)5 ReadAccountDetailsResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountDetailsResponse)5 ReadAccountListResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadAccountListResponse)5 ReadTransactionDetailsResponse (net.petafuel.styx.core.xs2a.standards.berlingroup.v1_2.http.ReadTransactionDetailsResponse)5 SEPAParsingException (net.petafuel.jsepa.exception.SEPAParsingException)3 Map (java.util.Map)2 LinkType (net.petafuel.styx.core.xs2a.entities.LinkType)2 PaymentStatus (net.petafuel.styx.core.xs2a.entities.PaymentStatus)2 OAuthTokenExpiredException (net.petafuel.styx.core.xs2a.exceptions.OAuthTokenExpiredException)2 RefreshTokenRequest (net.petafuel.styx.core.xs2a.oauth.http.RefreshTokenRequest)2 TaskFinalFailureException (net.petafuel.styx.keepalive.entities.TaskFinalFailureException)2