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