Search in sources :

Example 1 with Resources

use of org.springframework.hateoas.Resources in project amos-ss17-alexa by c-i-ber.

the class AccountFactory method getCardsForAccount.

/**
     * Get all cards (credit / debit) for the given account
     * @param number Account number
     * @return Collection of CardResponses
     * @throws URISyntaxException
     * @throws HttpClientErrorException
     */
public Collection<CardResponse> getCardsForAccount(String number) throws HttpClientErrorException {
    Traverson traverson = null;
    try {
        traverson = new Traverson(new URI(BankingRESTClient.BANKING_API_ENDPOINT + BankingRESTClient.BANKING_API_BASEURL_V1 + "/accounts/" + number + "/cards"), MediaTypes.HAL_JSON);
    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    ParameterizedTypeReference<Resources<CardResponse>> typeRefDevices = new ParameterizedTypeReference<Resources<CardResponse>>() {
    };
    Resources<CardResponse> resCardResponses = traverson.follow(rel("$._links.self.href")).toObject(typeRefDevices);
    Collection<CardResponse> cards = resCardResponses.getContent();
    return cards;
}
Also used : Traverson(org.springframework.hateoas.client.Traverson) CardResponse(model.banking.account.CardResponse) ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) URISyntaxException(java.net.URISyntaxException) Resources(org.springframework.hateoas.Resources) URI(java.net.URI)

Aggregations

URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 CardResponse (model.banking.account.CardResponse)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 Resources (org.springframework.hateoas.Resources)1 Traverson (org.springframework.hateoas.client.Traverson)1