Search in sources :

Example 1 with Account

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

the class AccountTest method testGetAccount.

/**
 * Account Information
 *
 * object path /api/v1_0/accounts/{accountnumber}
 *
 * https://s3.eu-central-1.amazonaws.com/amos-bank/api-guide.html#_konto_informationen
 */
@Test
public void testGetAccount() {
    Account account = AccountAPI.getAccount(ACCOUNT_NUMBER);
    // We can't check for balance here because maybe another transaction / standing order already modified the balance
    assertEquals(account.getNumber(), ACCOUNT_NUMBER);
    assertEquals(account.getOpeningDate(), getCurrentOpeningDate());
}
Also used : Account(model.banking.Account) Test(org.junit.Test)

Example 2 with Account

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

the class AffordabilityService method getAffordabilityResponse.

/**
 * response if the selected items is affordable or not referring the account balance
 *
 * @return SpeechletResponse
 */
private SpeechletResponse getAffordabilityResponse() {
    if (productSelectionSlot == null) {
        DialogUtil.setDialogState("which?", session);
        return getAskResponse(CARD, ERROR + " " + SELECTION_ASK);
    }
    if (productSelectionSlot.length() != 1) {
        DialogUtil.setDialogState("which?", session);
        return getAskResponse(CARD, ERROR + " " + SELECTION_ASK);
    }
    selectedItem = (Item) SessionStorage.getInstance().getObject(session.getSessionId(), "produkt " + productSelectionSlot.toLowerCase());
    if (selectedItem == null) {
        DialogUtil.setDialogState("which?", session);
        return getAskResponse(CARD, ERROR + " " + SELECTION_ASK);
    }
    // save selection in session
    SessionStorage.getInstance().putObject(session.getSessionId(), "selection", selectedItem);
    // get account data
    Account account = AccountAPI.getAccount(AccountData.ACCOUNT_FEW_MONEY);
    account.setSpeechTexts();
    Number balance = account.getBalance();
    if (selectedItem.getLowestNewPrice() / 100 > balance.doubleValue()) {
        DialogUtil.setDialogState("other?", session);
        return getSSMLAskResponse(CARD, getItemText(selectedItem) + " " + CANT_AFFORD + " " + account.getBalanceText() + " " + OTHER_SELECTION);
    }
    DialogUtil.setDialogState("email?", session);
    return getAskResponse(CARD, "Produkt " + productSelectionSlot + " " + selectedItem.getTitleShort() + " " + NOTE_ASK);
}
Also used : Account(model.banking.Account)

Example 3 with Account

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

the class AccountAPI method createAccount.

/**
 * Create account.
 *
 * @param accountNumber the account number
 * @param balance       the balance
 * @param openingDate   the opening date
 * @return the account
 */
public static Account createAccount(String accountNumber, Number balance, String openingDate) {
    Account newAccount = new Account();
    newAccount.setNumber(accountNumber);
    newAccount.setBalance(balance);
    newAccount.setOpeningDate(openingDate);
    return createAccount(newAccount);
}
Also used : Account(model.banking.Account)

Example 4 with Account

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

the class ContactTransferService method performTransfer.

/**
 * Performs the transfer.
 */
private SpeechletResponse performTransfer(Intent intent, 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;
    }
    DateTimeFormatter apiTransactionFmt = DateTimeFormat.forPattern("yyyy-MM-dd");
    String valueDate = DateTime.now().toString(apiTransactionFmt);
    Transaction transaction = TransactionAPI.createTransaction((int) amount, /*"DE50100000000000000001"*/
    AmosAlexaSpeechlet.ACCOUNT_IBAN, contact.getIban(), valueDate, "Beschreibung", "Hans", null);
    Account account = AccountAPI.getAccount(ACCOUNT_NUMBER);
    String balanceAfterTransaction = String.valueOf(account.getBalance());
    // save transaction id to save in db
    session.setAttribute(TRANSACTION_ID_ATTRIBUTE, transaction.getTransactionId().toString());
    // add category ask to success response
    String categoryAsk = "Zu welcher Kategorie soll die Transaktion hinzugefügt werden. Sag zum Beispiel Kategorie " + Category.categoryListText();
    return getAskResponse(CONTACT_TRANSFER_CARD, "Erfolgreich. " + amount + " Euro wurden an " + contact.getName() + " überwiesen. Dein neuer Kontostand beträgt " + balanceAfterTransaction + " Euro. " + categoryAsk);
}
Also used : Account(model.banking.Account) Transaction(model.banking.Transaction) LinkedList(java.util.LinkedList) List(java.util.List) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Contact(model.db.Contact)

Example 5 with Account

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

the class AccountFactory method createStandingOrders.

private void createStandingOrders(Account demoAccount, List<Account> contactAccounts) {
    for (Account contactAccount : contactAccounts) {
        StandingOrder standingOrder = AccountAPI.createStandingOrderForAccount(demoAccount.getNumber(), getContactName(contactAccount.getNumber()), 50, contactAccount.getIban(), TODAY_DATE, StandingOrder.ExecutionRate.MONTHLY, "Demo Dauerauftrag");
        dynamoDbMapper.save(new StandingOrderDB(demoAccount.getNumber(), standingOrder.getStandingOrderId().toString(), getRandomCategoryId()));
    }
}
Also used : Account(model.banking.Account) StandingOrder(model.banking.StandingOrder)

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