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 RecordEvent { 028 private Date startTime; 029 private String url; 030 private int size; 031 private String uuid; 032 private Date endTime; 033 private String conversationUuid; 034 private Date timestamp; 035 036 @JsonProperty("start_time") 037 public Date getStartTime() { 038 return startTime; 039 } 040 041 @JsonProperty("recording_url") 042 public String getUrl() { 043 return url; 044 } 045 046 public int getSize() { 047 return size; 048 } 049 050 @JsonProperty("recording_uuid") 051 public String getUuid() { 052 return uuid; 053 } 054 055 @JsonProperty("end_time") 056 public Date getEndTime() { 057 return endTime; 058 } 059 060 @JsonProperty("conversation_uuid") 061 public String getConversationUuid() { 062 return conversationUuid; 063 } 064 065 public Date getTimestamp() { 066 return timestamp; 067 } 068 069 public static RecordEvent fromJson(String json) { 070 try { 071 ObjectMapper mapper = new ObjectMapper(); 072 return mapper.readValue(json, RecordEvent.class); 073 } catch (IOException jpe) { 074 throw new VonageUnexpectedException("Failed to produce RecordEvent from json.", jpe); 075 } 076 } 077}