Search in sources :

Example 11 with Account

use of model.banking.Account in project amos-ss17-alexa by c-i-ber.

the class AccountFactory method createDemo.

/**
 * 7 transactions
 * 3 standing orders - with categories
 * 3 stocks
 * 5 categories with 3 keywords
 * 3 contacts with easy names
 */
public Account createDemo() {
    // Uncomment the following line to create and use NEW demo accounts
    // removeDemoAccounts();
    Account existingDemoAccount = getDemoAccount();
    if (existingDemoAccount != null) {
        return existingDemoAccount;
    }
    // user - needed for authenticating all following API calls
    createDemoUser();
    // account + savings account
    Account newDemoAccount = createDemoAccount();
    Account newDemoSavingsAccount = createSavingsAccount();
    saveAccount(newDemoAccount.getNumber(), newDemoSavingsAccount.getNumber(), true);
    // contact accounts
    List<Account> contactAccounts = createContactsAccount();
    saveContactAccounts(contactAccounts);
    // categories
    createCategories(newDemoAccount);
    // standing orders
    createStandingOrders(newDemoAccount, contactAccounts);
    // periodic transactions
    createPeriodicTransactions(newDemoAccount);
    return newDemoAccount;
}
Also used : Account(model.banking.Account)

Example 12 with Account

use of model.banking.Account in project amos-ss17-alexa by c-i-ber.

the class ContactTransferService method confirm.

private SpeechletResponse confirm(Session session) {
    Object contactsFoundObj = SESSION_STORAGE.getObject(session.getSessionId(), SESSION_PREFIX + ".contactsFound");
    if (contactsFoundObj == null || !(contactsFoundObj instanceof List)) {
        return getResponse(CONTACT_TRANSFER_CARD, "Da ist etwas schiefgegangen. Tut mir Leid.");
    }
    Object choiceObj = session.getAttribute(SESSION_PREFIX + ".choice");
    if (choiceObj == null || !(choiceObj instanceof Integer)) {
        return getResponse(CONTACT_TRANSFER_CARD, "Da ist etwas schiefgegangen. Tut mir Leid.");
    }
    Object amountObj = session.getAttribute(SESSION_PREFIX + ".amount");
    if (amountObj == null || !(amountObj instanceof Double || amountObj instanceof Integer)) {
        return getResponse(CONTACT_TRANSFER_CARD, "Da ist etwas schiefgegangen. Tut mir Leid.");
    }
    Contact contact = ((List<Contact>) contactsFoundObj).get((int) choiceObj - 1);
    double amount;
    if (amountObj instanceof Double) {
        amount = (double) amountObj;
    } else {
        amount = (int) amountObj;
    }
    session.setAttribute(DIALOG_CONTEXT, CONTACT_CHOICE_INTENT);
    Account account = AccountAPI.getAccount(ACCOUNT_NUMBER);
    String balanceBeforeTransation = String.valueOf(account.getBalance());
    return getAskResponse(CONTACT_TRANSFER_CARD, "Dein aktueller Kontostand beträgt " + balanceBeforeTransation + " Euro. Möchtest du " + amount + " Euro an " + contact.getName() + " überweisen?");
}
Also used : Account(model.banking.Account) LinkedList(java.util.LinkedList) List(java.util.List) Contact(model.db.Contact)

Aggregations

Account (model.banking.Account)12 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Contact (model.db.Contact)2 IntentRequest (com.amazon.speech.speechlet.IntentRequest)1 Session (com.amazon.speech.speechlet.Session)1 ArrayList (java.util.ArrayList)1 StandingOrder (model.banking.StandingOrder)1 Transaction (model.banking.Transaction)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 Test (org.junit.Test)1