use of model.banking.account.CardResponse 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 model.banking.account.CardResponse in project amos-ss17-alexa by c-i-ber.
the class ReplacementCardDialog method askForCardNumber.
private SpeechletResponse askForCardNumber(SessionStorage.Storage storage, boolean errored) {
// TODO: Load account from session
Collection<CardResponse> cards = AccountFactory.getInstance().getCardsForAccount("0000000000");
if (cards.size() == 0) {
// This user does not have any cards, ordering a replacement card is impossible.
PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText("Es wurden keine Kredit- oder EC-Karten gefunden.");
return SpeechletResponse.newTellResponse(speech);
} else {
SsmlOutputSpeech speech = new SsmlOutputSpeech();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<speak>");
if (errored) {
stringBuilder.append("Entschuldigung, das habe ich nicht verstanden. ");
}
stringBuilder.append("Bestellung einer Ersatzkarte. Es wurden folgende Karten gefunden: ");
List<String> userCards = new ArrayList<>();
for (CardResponse card : cards) {
// Check if this card is active
if (card.status != CardResponse.Status.ACTIVE) {
continue;
}
userCards.add(card.cardNumber);
String prefix = (card.cardType == CardResponse.CardType.CREDIT ? "Kredit" : "EC-");
stringBuilder.append(prefix + "karte mit den Endziffern <say-as interpret-as=\"digits\">" + card.cardNumber.substring(card.cardNumber.length() - 4) + "</say-as>. ");
}
// Store all card numbers in the session
storage.put(STORAGE_VALID_CARDS, userCards);
stringBuilder.append("Bitte gib die Endziffern der Karte an, für die du Ersatz benötigst.");
stringBuilder.append("</speak>");
speech.setSsml(stringBuilder.toString());
// Create reprompt
Reprompt reprompt = new Reprompt();
reprompt.setOutputSpeech(speech);
return SpeechletResponse.newAskResponse(speech, reprompt);
}
}
Aggregations