Search in sources :

Example 11 with StandingOrder

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

the class AccountAPI method createStandingOrderForAccount.

/**
 * Create standing order.
 *
 * @param accountNumber      the account number
 * @param payee              the payee
 * @param amount             the amount
 * @param destinationAccount the destination account
 * @param firstExecution     the first execution
 * @param executionRate      the execution rate
 * @param description        the description
 * @return the standing order
 */
public static StandingOrder createStandingOrderForAccount(String accountNumber, String payee, Number amount, String destinationAccount, String firstExecution, StandingOrder.ExecutionRate executionRate, String description) {
    StandingOrder newStandingOrder = new StandingOrder();
    newStandingOrder.setPayee(payee);
    newStandingOrder.setAmount(amount);
    newStandingOrder.setDestinationAccount(destinationAccount);
    newStandingOrder.setFirstExecution(firstExecution);
    newStandingOrder.setExecutionRate(executionRate);
    newStandingOrder.setDescription(description);
    return createStandingOrderForAccount(accountNumber, newStandingOrder);
}
Also used : StandingOrder(model.banking.StandingOrder)

Example 12 with StandingOrder

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

the class AmosAlexaSimpleTestImpl method standingOrderCreateSmartIntentTest.

@Test
public void standingOrderCreateSmartIntentTest() throws IllegalAccessException, NoSuchFieldException, IOException {
    newSession();
    Collection<StandingOrder> standingOrdersCollection = AccountAPI.getStandingOrdersForAccount("9999999999");
    List<StandingOrder> standingOrders = new ArrayList<>(standingOrdersCollection);
    for (StandingOrder standingOrder : standingOrders) {
        if (standingOrder.getPayee().toLowerCase().equals("max mustermann")) {
            String orderAmount = standingOrder.getAmount().toString();
            testIntent("StandingOrderSmartIntent", "Payee:max", "PayeeSecondName:mustermann", "orderAmount:10", "Der Dauerauftrag für max mustermann über " + orderAmount + " Euro existiert schon. Möchtest du diesen aktualisieren");
            testIntent("StandingOrderSmartIntent", "Der neue Dauerauftrag für max mustermann über 10 Euro wurde erfolgreich eingerichtet");
            break;
        }
    }
}
Also used : StandingOrder(model.banking.StandingOrder) Test(org.junit.Test)

Example 13 with StandingOrder

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

the class AmosAlexaSimpleTestImpl method standingOrderUpdateSmartIntentTest.

@Test
public void standingOrderUpdateSmartIntentTest() throws IllegalAccessException, NoSuchFieldException, IOException {
    newSession();
    Collection<StandingOrder> standingOrdersCollection = AccountAPI.getStandingOrdersForAccount("9999999999");
    List<StandingOrder> standingOrders = new ArrayList<>(standingOrdersCollection);
    for (StandingOrder standingOrder : standingOrders) {
        if (standingOrder.getPayee().toLowerCase().equals("max mustermann")) {
            String orderAmount = standingOrder.getAmount().toString();
            testIntent("StandingOrderSmartIntent", "Payee:max", "PayeeSecondName:mustermann", "orderAmount:10", "Der Dauerauftrag für max mustermann über " + orderAmount + " Euro existiert schon. Möchtest du diesen aktualisieren");
            // "Der Dauerauftrag Nummer " + standingOrder.getStandingOrderId() + " für Max Mustermann über 10 euro wurde erfolgreich aktualisiert");
            break;
        }
    }
}
Also used : StandingOrder(model.banking.StandingOrder) Test(org.junit.Test)

Example 14 with StandingOrder

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

the class AccountTest method testCreateAndGetStandingOrder.

@Test
public void testCreateAndGetStandingOrder() {
    String firstExecution = new DateTime(2018, 5, 1, 12, 0).toLocalDate().toString();
    StandingOrder standingOrder = AccountAPI.createStandingOrderForAccount(ACCOUNT_NUMBER, "Test", 123, ACCOUNT_NUMBER2, firstExecution, StandingOrder.ExecutionRate.MONTHLY, "Description");
    assertEquals(standingOrder.getPayee(), "Test");
    assertEquals(standingOrder.getAmount(), 123);
    assertEquals(standingOrder.getDestinationAccount(), ACCOUNT_NUMBER2);
    assertEquals(standingOrder.getFirstExecution(), firstExecution);
    assertEquals(standingOrder.getExecutionRate(), StandingOrder.ExecutionRate.MONTHLY);
    assertEquals(standingOrder.getDescription(), "Description");
    // Get standing orders
    Collection<StandingOrder> standingOrders = AccountAPI.getStandingOrdersForAccount(ACCOUNT_NUMBER);
    boolean foundStandingOrder = false;
    for (StandingOrder standingOrder1 : standingOrders) {
        if (standingOrder1.getStandingOrderId().equals(standingOrder.getStandingOrderId())) {
            foundStandingOrder = true;
            break;
        }
    }
    assertTrue(foundStandingOrder);
}
Also used : StandingOrder(model.banking.StandingOrder) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 15 with StandingOrder

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

the class StandingOrderService method smartCreateStandingOrderResponse.

/**
 * Creates a {@code SpeechletResponse} for the standing orders intent.
 *
 * @return SpeechletResponse spoken and visual response for the given intent
 */
private SpeechletResponse smartCreateStandingOrderResponse(Session session) {
    SimpleCard card = new SimpleCard();
    card.setTitle("Daueraufträge");
    LOGGER.info("SmartStandingOrders create called.");
    int standingOrderToModify = (int) session.getAttribute("StandingOrderToModify");
    String newAmount = (String) session.getAttribute("NewAmount");
    StandingOrder oldStandingOrder = AccountAPI.getStandingOrder(ACCOUNT_NUMBER, standingOrderToModify);
    StandingOrder standingOrder = new StandingOrder();
    standingOrder.setAmount(Integer.parseInt(newAmount));
    standingOrder.setDescription("description");
    standingOrder.setDestinationAccount(oldStandingOrder.getDestinationAccount());
    standingOrder.setExecutionRate(oldStandingOrder.getExecutionRate());
    standingOrder.setFirstExecution(oldStandingOrder.getFirstExecution());
    standingOrder.setPayee(oldStandingOrder.getPayee());
    standingOrder.setSourceAccount(oldStandingOrder.getSourceAccount());
    standingOrder.setStatus(oldStandingOrder.getStatus());
    AccountAPI.createStandingOrderForAccount(ACCOUNT_NUMBER, standingOrder);
    // Create the plain text output
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    speech.setText("Der neue Dauerauftrag für " + oldStandingOrder.getPayee().toLowerCase() + " über " + newAmount + " Euro wurde erfolgreich eingerichtet");
    // delete session attributes
    session.removeAttribute("SmartCreateStandingOrderIntent");
    session.removeAttribute("StandingOrderToModify");
    session.removeAttribute("NewAmount");
    // Create reprompt
    Reprompt reprompt = new Reprompt();
    reprompt.setOutputSpeech(speech);
    return SpeechletResponse.newTellResponse(speech, card);
}
Also used : StandingOrder(model.banking.StandingOrder) SimpleCard(com.amazon.speech.ui.SimpleCard) Reprompt(com.amazon.speech.ui.Reprompt) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech)

Aggregations

StandingOrder (model.banking.StandingOrder)15 Test (org.junit.Test)5 PlainTextOutputSpeech (com.amazon.speech.ui.PlainTextOutputSpeech)4 SimpleCard (com.amazon.speech.ui.SimpleCard)4 Slot (com.amazon.speech.slu.Slot)3 Reprompt (com.amazon.speech.ui.Reprompt)3 SsmlOutputSpeech (com.amazon.speech.ui.SsmlOutputSpeech)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Account (model.banking.Account)1 Category (model.db.Category)1 Contact (model.db.Contact)1 DateTime (org.joda.time.DateTime)1 ParameterizedTypeReference (org.springframework.core.ParameterizedTypeReference)1 Resources (org.springframework.hateoas.Resources)1 Traverson (org.springframework.hateoas.client.Traverson)1