001/* 002 * Copyright 2020 Vonage 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.vonage.client.incoming; 017 018import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 019import com.fasterxml.jackson.annotation.JsonProperty; 020import com.fasterxml.jackson.databind.ObjectMapper; 021import com.vonage.client.VonageUnexpectedException; 022 023import java.io.IOException; 024import java.util.Date; 025 026@JsonIgnoreProperties(ignoreUnknown = true) 027public class InputEvent { 028 private String uuid; 029 private String conversationUuid; 030 private boolean timedOut; 031 private String dtmf; 032 private Date timestamp; 033 034 public String getUuid() { 035 return uuid; 036 } 037 038 @JsonProperty("conversation_uuid") 039 public String getConversationUuid() { 040 return conversationUuid; 041 } 042 043 @JsonProperty("timed_out") 044 public boolean isTimedOut() { 045 return timedOut; 046 } 047 048 public String getDtmf() { 049 return dtmf; 050 } 051 052 public Date getTimestamp() { 053 return timestamp; 054 } 055 056 public static InputEvent fromJson(String json) { 057 try { 058 ObjectMapper mapper = new ObjectMapper(); 059 return mapper.readValue(json, InputEvent.class); 060 } catch (IOException jpe) { 061 throw new VonageUnexpectedException("Failed to produce InputEvent from json.", jpe); 062 } 063 } 064}