use of com.amazonaws.util.json.JSONObject 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);
}
use of com.amazonaws.util.json.JSONObject in project nutch by apache.
the class CloudSearchIndexWriter method delete.
@Override
public void delete(String url) throws IOException {
try {
JSONObject doc_builder = new JSONObject();
doc_builder.put("type", "delete");
// generate the id from the url
String ID = CloudSearchUtils.getID(url);
doc_builder.put("id", ID);
// add to the batch
addToBatch(doc_builder.toString(2), url);
} catch (JSONException e) {
LOG.error("Exception caught while building JSON object", e);
}
}
use of com.amazonaws.util.json.JSONObject in project nutch by apache.
the class CloudSearchIndexWriter method write.
@Override
public void write(NutchDocument doc) throws IOException {
try {
JSONObject doc_builder = new JSONObject();
doc_builder.put("type", "add");
String url = doc.getField("url").toString();
// generate the id from the url
String ID = CloudSearchUtils.getID(url);
doc_builder.put("id", ID);
JSONObject fields = new JSONObject();
for (final Entry<String, NutchField> e : doc) {
String fieldname = cleanFieldName(e.getKey());
String type = csfields.get(fieldname);
// undefined in index
if (!dumpBatchFilesToTemp && type == null) {
LOG.info("Field {} not defined in CloudSearch domain for {} - skipping.", fieldname, url);
continue;
}
List<Object> values = e.getValue().getValues();
// write the values
for (Object value : values) {
// Convert dates to an integer
if (value instanceof Date) {
Date d = (Date) value;
value = DATE_FORMAT.format(d);
} else // normalise strings
if (value instanceof String) {
value = CloudSearchUtils.stripNonCharCodepoints((String) value);
}
fields.accumulate(fieldname, value);
}
}
doc_builder.put("fields", fields);
addToBatch(doc_builder.toString(2), url);
} catch (JSONException e) {
LOG.error("Exception caught while building JSON object", e);
}
}
Aggregations