Search in sources :

Example 1 with BankingRESTClient

use of api.BankingRESTClient in project amos-ss17-alexa by c-i-ber.

the class SavingsPlanDialog method createSavingsPlanOneOffPayment.

private void createSavingsPlanOneOffPayment(String betrag) {
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("amount", betrag);
        //TODO Hard coded savings account?
        jsonObject.put("sourceAccount", "DE42100000009999999999");
        jsonObject.put("destinationAccount", "DE39100000007777777777");
        jsonObject.put("valueDate", "2017-05-24");
        jsonObject.put("description", "Savings Plan");
    } catch (JSONException e) {
        LOGGER.error(e.getMessage());
    }
    BankingRESTClient bankingRESTClient = BankingRESTClient.getInstance();
    //TODO Post mapped to Object.class
    bankingRESTClient.postBankingModelObject("/api/v1_0/transactions", jsonObject.toString(), Object.class);
}
Also used : JSONObject(com.amazonaws.util.json.JSONObject) JSONException(com.amazonaws.util.json.JSONException) BankingRESTClient(api.BankingRESTClient)

Example 2 with BankingRESTClient

use of api.BankingRESTClient in project amos-ss17-alexa by c-i-ber.

the class AccountFactory method createAccount.

public Account createAccount(String number, Double balance, String openingDate) throws JSONException {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("number", number);
    jsonObject.put("balance", balance);
    jsonObject.put("openingDate", openingDate);
    BankingRESTClient bankingRESTClient = BankingRESTClient.getInstance();
    return (Account) bankingRESTClient.postBankingModelObject("/api/v1_0/accounts/generate", jsonObject.toString(), Account.class);
}
Also used : Account(model.banking.account.Account) JSONObject(com.amazonaws.util.json.JSONObject) BankingRESTClient(api.BankingRESTClient)

Example 3 with BankingRESTClient

use of api.BankingRESTClient in project amos-ss17-alexa by c-i-ber.

the class SavingsPlanDialog method createSavingsPlanStandingOrder.

private void createSavingsPlanStandingOrder(String monatlicheZahlung) {
    JSONObject jsonObject = new JSONObject();
    try {
        jsonObject.put("payee", "Max Mustermann");
        jsonObject.put("amount", monatlicheZahlung);
        //TODO Hard coded savings account?
        jsonObject.put("destinationAccount", "DE39100000007777777777");
        jsonObject.put("firstExecution", "2017-06-01");
        jsonObject.put("executionRate", "MONTHLY");
        jsonObject.put("description", "Savings Plan");
    } catch (JSONException e) {
        LOGGER.error(e.getMessage());
    }
    BankingRESTClient bankingRESTClient = BankingRESTClient.getInstance();
    bankingRESTClient.postBankingModelObject("/api/v1_0/accounts/9999999999/standingorders", jsonObject.toString(), StandingOrder.class);
}
Also used : JSONObject(com.amazonaws.util.json.JSONObject) JSONException(com.amazonaws.util.json.JSONException) BankingRESTClient(api.BankingRESTClient)

Example 4 with BankingRESTClient

use of api.BankingRESTClient in project amos-ss17-alexa by c-i-ber.

the class StandingOrderDialog method getStandingOrdersModifyResponse.

private SpeechletResponse getStandingOrdersModifyResponse(Intent intent, SessionStorage.Storage storage) {
    String standingOrderToModify = (String) storage.get("StandingOrderToModify");
    String newAmount = (String) storage.get("NewAmount");
    String newExecutionRate = (String) storage.get("NewExecutionRate");
    String newFirstExecution = (String) storage.get("NewFirstExecution");
    ObjectMapper mapper = new ObjectMapper();
    // Create the Simple card content.
    SimpleCard card = new SimpleCard();
    card.setTitle("Ändere Dauerauftrag");
    // Create the plain text output.
    PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
    JSONObject jsonObject = new JSONObject();
    try {
        //TODO
        jsonObject.put("payee", "Max Mustermann");
        jsonObject.put("amount", newAmount);
        jsonObject.put("destinationAccount", "DE39100000007777777777");
        jsonObject.put("firstExecution", "2017-06-01");
        jsonObject.put("executionRate", "MONTHLY");
        jsonObject.put("description", "Updated standing Order");
    } catch (JSONException e) {
        LOGGER.error(e.getMessage());
    }
    BankingRESTClient bankingRESTClient = BankingRESTClient.getInstance();
    bankingRESTClient.putBankingModelObject("/api/v1_0/accounts/9999999999/standingorders/" + standingOrderToModify, jsonObject.toString(), StandingOrder.class);
    card.setContent("Dauerauftrag Nummer " + standingOrderToModify + " wurde geändert.");
    speech.setText("Dauerauftrag Nummer " + standingOrderToModify + " wurde geaendert.");
    return SpeechletResponse.newTellResponse(speech, card);
}
Also used : JSONObject(com.amazonaws.util.json.JSONObject) SimpleCard(com.amazon.speech.ui.SimpleCard) JSONException(com.amazonaws.util.json.JSONException) PlainTextOutputSpeech(com.amazon.speech.ui.PlainTextOutputSpeech) BankingRESTClient(api.BankingRESTClient) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

BankingRESTClient (api.BankingRESTClient)4 JSONObject (com.amazonaws.util.json.JSONObject)4 JSONException (com.amazonaws.util.json.JSONException)3 PlainTextOutputSpeech (com.amazon.speech.ui.PlainTextOutputSpeech)1 SimpleCard (com.amazon.speech.ui.SimpleCard)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Account (model.banking.account.Account)1