001/* 002 * Copyright 2024 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.voice; 017 018import com.fasterxml.jackson.annotation.JsonProperty; 019import com.vonage.client.Jsonable; 020import com.vonage.client.JsonableBaseObject; 021import java.util.Date; 022 023/** 024 * CallInfo holds the information related to a call. It is obtained using {@link VoiceClient#listCalls()}. 025 */ 026public class CallInfo extends JsonableBaseObject { 027 Endpoint from, to; 028 String conversationUuid, uuid, network, price, rate; 029 CallDirection direction; 030 Integer duration; 031 Date startTime, endTime; 032 CallStatus status; 033 034 CallInfo() {} 035 036 CallInfo(String to, String from) { 037 this(new PhoneEndpoint(to), new PhoneEndpoint(from)); 038 } 039 040 CallInfo(Endpoint to, Endpoint from) { 041 this.to = to; 042 this.from = from; 043 } 044 045 @JsonProperty("to") 046 public Endpoint getTo() { 047 return to; 048 } 049 050 @JsonProperty("from") 051 public Endpoint getFrom() { 052 return from; 053 } 054 055 @JsonProperty("uuid") 056 public String getUuid() { 057 return uuid; 058 } 059 060 @JsonProperty("conversation_uuid") 061 public String getConversationUuid() { 062 return conversationUuid; 063 } 064 065 @JsonProperty("duration") 066 public Integer getDuration() { 067 return duration; 068 } 069 070 @JsonProperty("end_time") 071 public Date getEndTime() { 072 return endTime; 073 } 074 075 @JsonProperty("price") 076 public String getPrice() { 077 return price; 078 } 079 080 @JsonProperty("rate") 081 public String getRate() { 082 return rate; 083 } 084 085 @JsonProperty("start_time") 086 public Date getStartTime() { 087 return this.startTime; 088 } 089 090 @JsonProperty("status") 091 public CallStatus getStatus() { 092 return status; 093 } 094 095 @JsonProperty("direction") 096 public CallDirection getDirection() { 097 return direction; 098 } 099 100 @JsonProperty("network") 101 public String getNetwork() { 102 return network; 103 } 104 105 @Override 106 public String toString() { 107 return "<CallInfo " + 108 "ID: " + this.getUuid() + ", " + 109 "From: " + this.getFrom().toLog() + ", " + 110 "To: " + this.getTo().toLog() + ", " + 111 "Status: " + this.getStatus() + 112 ">"; 113 } 114 115 /** 116 * Creates an instance of this class from a JSON payload. 117 * 118 * @param json The JSON string to parse. 119 * 120 * @return An instance of this class with the fields populated, if present. 121 */ 122 public static CallInfo fromJson(String json) { 123 return Jsonable.fromJson(json); 124 } 125}