use of org.springframework.hateoas.client.Traverson in project amos-ss17-alexa by c-i-ber.
the class AccountAPI method getCardsForAccount.
/**
* Get all cards (credit / debit) for the given account.
*
* @param accountNumber Account number
* @return Collection of Cards
* @throws HttpClientErrorException
*/
public static Collection<Card> getCardsForAccount(String accountNumber) throws HttpClientErrorException {
// TODO: Create a generic method for getting embedded JSON-HAL collections (in BankingRESTClient)
Traverson traverson = null;
try {
traverson = new Traverson(new URI(BankingRESTClient.BANKING_API_ENDPOINT + BankingRESTClient.BANKING_API_BASEURL_V2 + "/accounts/" + accountNumber + "/cards"), MediaTypes.HAL_JSON);
} catch (URISyntaxException e) {
log.error("getCardsForAccount failed", e);
return null;
}
ParameterizedTypeReference<Resources<Card>> typeRefDevices = new ParameterizedTypeReference<Resources<Card>>() {
};
Resources<Card> resResponses = traverson.follow(rel("$._links.self.href")).withHeaders(bankingRESTClient.generateHttpHeaders()).toObject(typeRefDevices);
return resResponses.getContent();
}
use of org.springframework.hateoas.client.Traverson in project amos-ss17-alexa by c-i-ber.
the class TransactionAPI method getTransactions.
/**
* Get all transactions for the given account.
*
* @param accountNumber Account number
* @return Collection of Cards
* @throws HttpClientErrorException
*/
private static Collection<Transaction> getTransactions(String accountNumber) throws HttpClientErrorException {
// TODO: Create a generic method for getting embedded JSON-HAL collections (in BankingRESTClient)
Traverson traverson = null;
String uri = BankingRESTClient.BANKING_API_ENDPOINT + BankingRESTClient.BANKING_API_BASEURL_V2 + "/accounts/" + accountNumber + "/transactions";
log.info("URI: " + uri);
try {
traverson = new Traverson(new URI(uri), MediaTypes.HAL_JSON);
} catch (URISyntaxException e) {
log.error("getTransactionsForAccount failed", e);
return null;
}
ParameterizedTypeReference<Resources<Transaction>> typeRefDevices = new ParameterizedTypeReference<Resources<Transaction>>() {
};
Resources<Transaction> resResponses = traverson.follow(rel("$._links.self.href")).withHeaders(bankingRESTClient.generateHttpHeaders()).toObject(typeRefDevices);
return resResponses.getContent();
}
use of org.springframework.hateoas.client.Traverson 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;
}
use of org.springframework.hateoas.client.Traverson in project amos-ss17-alexa by c-i-ber.
the class AccountAPI method getStandingOrdersForAccount.
/**
* Get all standing orders for the given account.
*
* @param accountNumber Account number
* @return Collection of StandingOrders
* @throws HttpClientErrorException
*/
public static Collection<StandingOrder> getStandingOrdersForAccount(String accountNumber) throws HttpClientErrorException {
// TODO: Create a generic method for getting embedded JSON-HAL collections (in BankingRESTClient)
Traverson traverson = null;
try {
traverson = new Traverson(new URI(BankingRESTClient.BANKING_API_ENDPOINT + BankingRESTClient.BANKING_API_BASEURL_V2 + "/accounts/" + accountNumber + "/standingorders"), MediaTypes.HAL_JSON);
} catch (URISyntaxException e) {
log.error("getStandingOrdersForAccount failed", e);
return null;
}
ParameterizedTypeReference<Resources<StandingOrder>> typeRefDevices = new ParameterizedTypeReference<Resources<StandingOrder>>() {
};
Resources<StandingOrder> resResponses = traverson.follow(rel("$._links.self.href")).withHeaders(bankingRESTClient.generateHttpHeaders()).toObject(typeRefDevices);
return resResponses.getContent();
}
use of org.springframework.hateoas.client.Traverson in project amos-ss17-alexa by c-i-ber.
the class SecuritiesAccountAPI method getSecuritiesForAccount.
/**
* Get all securities for the given securities account.
*
* @param securitiesAccountNumber Account number
* @return Collection of securities
* @throws HttpClientErrorException
*/
public static Collection<Security> getSecuritiesForAccount(Number securitiesAccountNumber) throws HttpClientErrorException {
// TODO: Create a generic method for getting embedded JSON-HAL collections (in BankingRESTClient)
Traverson traverson = null;
try {
traverson = new Traverson(new URI(BankingRESTClient.BANKING_API_ENDPOINT + BankingRESTClient.BANKING_API_BASEURL_V2 + "/securitiesAccounts/" + securitiesAccountNumber), MediaTypes.HAL_JSON);
} catch (URISyntaxException e) {
LOGGER.error("getSecuritiesForAccount failed", e);
return null;
}
ParameterizedTypeReference<Resources<Security>> typeRefDevices = new ParameterizedTypeReference<Resources<Security>>() {
};
Resources<Security> resResponses = traverson.follow(rel("$._links.self.href")).withHeaders(bankingRESTClient.generateHttpHeaders()).toObject(typeRefDevices);
return resResponses.getContent();
}
Aggregations