use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.
the class BasicAuthorisationService method authoriseTransaction.
protected SCA authoriseTransaction(AuthoriseTransactionRequest authoriseTransactionRequest) throws BankRequestFailedException {
this.setUrl(this.url + authoriseTransactionRequest.getServicePath());
this.createBody(RequestType.PUT, JSON, authoriseTransactionRequest);
this.createHeaders(authoriseTransactionRequest);
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);
}
}
use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.
the class BasicAuthorisationService method getAuthorisations.
protected List<String> getAuthorisations(GetAuthorisationsRequest 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);
GetAuthorisationResponse getAuthorisationResponse = jsonb.fromJson(responseBody, GetAuthorisationResponse.class);
return getAuthorisationResponse.getAuthorisationIds();
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.
the class BasicAuthorisationService method updatePSUAuthentication.
protected SCA updatePSUAuthentication(UpdatePSUAuthenticationRequest updatePSUAuthenticationRequest) throws BankRequestFailedException {
this.setUrl(this.url + updatePSUAuthenticationRequest.getServicePath());
this.createBody(RequestType.PUT, JSON, updatePSUAuthenticationRequest);
this.createHeaders(updatePSUAuthenticationRequest);
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);
}
}
use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.
the class BerlinGroupCS method getConsent.
@Override
public Consent getConsent(AISRequest consentGetRequest) throws BankRequestFailedException {
this.setUrl(this.url + consentGetRequest.getServicePath());
this.createBody(RequestType.GET);
this.createHeaders(consentGetRequest);
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create()) {
String responseBody = extractResponseBody(response, 200);
Consent consentFromResponse = jsonb.fromJson(responseBody, Consent.class);
consentFromResponse.setId(consentGetRequest.getConsentId());
Consent consentFromDatabase = new PersistentConsent().get(consentFromResponse);
consentFromDatabase.setAccess(consentFromResponse.getAccess());
consentFromDatabase.setRecurringIndicator(consentFromResponse.isRecurringIndicator());
consentFromDatabase.setValidUntil(consentFromResponse.getValidUntil());
consentFromDatabase.setFrequencyPerDay(consentFromResponse.getFrequencyPerDay());
consentFromDatabase.setState(consentFromResponse.getState());
consentFromDatabase.setLastAction(consentFromResponse.getLastAction());
return new PersistentConsent().update(consentFromDatabase);
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
use of net.petafuel.styx.core.xs2a.exceptions.BankRequestFailedException in project styx by petafuel.
the class BerlinGroupCS method createConsent.
public Consent createConsent(AISRequest consentRequest) throws BankRequestFailedException {
this.setUrl(this.url + consentRequest.getServicePath());
this.createBody(RequestType.POST, JSON, consentRequest);
this.createHeaders(consentRequest);
JsonbConfig config = new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.CASE_INSENSITIVE);
try (Response response = this.execute();
Jsonb jsonb = JsonbBuilder.create(config)) {
String responseBody = extractResponseBody(response, 201);
Consent consent = jsonb.fromJson(responseBody, Consent.class);
consent.setxRequestId(UUID.fromString(consentRequest.getHeaders().get("x-request-id")));
consent.setPsu(consentRequest.getPsu());
// if the sca method was not set by previously parsing the body, use the bank supplied header
consent.getSca().setApproach(SCAUtils.parseSCAApproach(consent.getLinks(), response));
consent.setAccess(consentRequest.getConsent().getAccess());
new PersistentConsent().create(consent);
return consent;
} catch (BankRequestFailedException e) {
throw e;
} catch (Exception e) {
throw new BankRequestFailedException(e.getMessage(), e);
}
}
Aggregations