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 CallEvent { 028 private String conversationUuid; 029 private CallDirection direction; 030 private String from; 031 private CallStatus status; 032 private Date timestamp; 033 private String to; 034 private String uuid; 035 036 @JsonProperty("conversation_uuid") 037 public String getConversationUuid() { 038 return conversationUuid; 039 } 040 041 public CallDirection getDirection() { 042 return direction; 043 } 044 045 public String getFrom() { 046 return from; 047 } 048 049 public CallStatus getStatus() { 050 return status; 051 } 052 053 public Date getTimestamp() { 054 return timestamp; 055 } 056 057 public String getTo() { 058 return to; 059 } 060 061 public String getUuid() { 062 return uuid; 063 } 064 065 public static CallEvent fromJson(String json) { 066 try { 067 ObjectMapper mapper = new ObjectMapper(); 068 return mapper.readValue(json, CallEvent.class); 069 } catch (IOException jpe) { 070 throw new VonageUnexpectedException("Failed to produce CallEvent from json.", jpe); 071 } 072 } 073}