Search in sources :

Example 1 with AccountAccess

use of net.petafuel.styx.core.xs2a.entities.AccountAccess in project styx by petafuel.

the class ConsentResourcesTest method createConsentEndpoint.

Response createConsentEndpoint() {
    Invocation.Builder invocationBuilder = getInvocationBuilder(String.format(POST_CONSENT, consentId));
    POSTConsentRequest request = new POSTConsentRequest();
    request.setAccess(new AccountAccess());
    request.getAccess().setAccounts(new ArrayList<>());
    request.getAccess().getAccounts().add(getAccountReference());
    request.getAccess().setBalances(new ArrayList<>());
    request.getAccess().getBalances().add(getAccountReference());
    request.getAccess().setTransactions(new ArrayList<>());
    request.getAccess().getTransactions().add(getAccountReference());
    request.setRecurringIndicator(true);
    Invocation invocation = invocationBuilder.buildPost(Entity.entity(request, MediaType.APPLICATION_JSON));
    return invocation.invoke(Response.class);
}
Also used : Invocation(javax.ws.rs.client.Invocation) AccountAccess(net.petafuel.styx.core.xs2a.entities.AccountAccess) POSTConsentRequest(net.petafuel.styx.api.v1.consent.entity.POSTConsentRequest)

Example 2 with AccountAccess

use of net.petafuel.styx.core.xs2a.entities.AccountAccess in project styx by petafuel.

the class PersistentConsent method dbToModel.

/**
 * Maps the query ResultSet to a consent model
 *
 * @param resultSet Result set of a selecting database function
 * @return Mapped Consent from the database columns
 * @throws SQLException If the expected database column is not available
 */
private Consent dbToModel(ResultSet resultSet) throws SQLException {
    Consent consent = new Consent();
    consent.setId(resultSet.getString("id"));
    try (Jsonb jsonb = JsonbBuilder.create()) {
        AccountAccess consentAccess = jsonb.fromJson(resultSet.getString("access"), AccountAccess.class);
        consent.setAccess(consentAccess);
    } catch (Exception e) {
        throw new SerializerException(e.getMessage(), e);
    }
    consent.setRecurringIndicator(resultSet.getBoolean("recurring_indicator"));
    consent.setLastAction(getDateFromTimestamp(resultSet.getTimestamp("last_action")));
    consent.setValidUntil(getDateFromTimestamp(resultSet.getTimestamp("valid_until")));
    consent.setLastUpdated(getDateFromTimestamp(resultSet.getTimestamp("last_updated")));
    consent.setCreatedAt(getDateFromTimestamp(resultSet.getTimestamp("created_at")));
    consent.setFrequencyPerDay(resultSet.getInt("frequency_per_day"));
    consent.setState(ConsentStatus.getByString(resultSet.getString("state")));
    consent.getSca().setApproach(SCA.Approach.valueOf(resultSet.getString("chosen_sca_method")));
    consent.setCombinedServiceIndicator(resultSet.getBoolean("combined_service_indicator"));
    consent.setxRequestId(UUID.fromString(resultSet.getString("x_request_id")));
    PSU psu = new PSU(resultSet.getString("psu_id"));
    psu.setIdType(resultSet.getString("psu_id_type"));
    psu.setIp(resultSet.getString("psu_ip_address"));
    psu.setPort(resultSet.getInt("psu_ip_port"));
    psu.setUserAgent(resultSet.getString("psu_user_agent"));
    psu.setGeoLocation(resultSet.getString("psu_geo_location"));
    psu.setCorporateId(resultSet.getString("psu_corporate_id"));
    psu.setCorporateIdType(resultSet.getString("psu_corporate_id_type"));
    consent.setPsu(psu);
    return consent;
}
Also used : Jsonb(javax.json.bind.Jsonb) PSU(net.petafuel.styx.core.xs2a.entities.PSU) Consent(net.petafuel.styx.core.xs2a.entities.Consent) AccountAccess(net.petafuel.styx.core.xs2a.entities.AccountAccess) SerializerException(net.petafuel.styx.core.xs2a.exceptions.SerializerException) SerializerException(net.petafuel.styx.core.xs2a.exceptions.SerializerException) PersistenceException(net.petafuel.styx.core.persistence.PersistenceException) SQLException(java.sql.SQLException)

Aggregations

AccountAccess (net.petafuel.styx.core.xs2a.entities.AccountAccess)2 SQLException (java.sql.SQLException)1 Jsonb (javax.json.bind.Jsonb)1 Invocation (javax.ws.rs.client.Invocation)1 POSTConsentRequest (net.petafuel.styx.api.v1.consent.entity.POSTConsentRequest)1 PersistenceException (net.petafuel.styx.core.persistence.PersistenceException)1 Consent (net.petafuel.styx.core.xs2a.entities.Consent)1 PSU (net.petafuel.styx.core.xs2a.entities.PSU)1 SerializerException (net.petafuel.styx.core.xs2a.exceptions.SerializerException)1