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;
}
Aggregations