001/* 002 * Copyright (c) 2011-2017 Nexmo Inc 003 * 004 * Permission is hereby granted, free of charge, to any person obtaining a copy 005 * of this software and associated documentation files (the "Software"), to deal 006 * in the Software without restriction, including without limitation the rights 007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 008 * copies of the Software, and to permit persons to whom the Software is 009 * furnished to do so, subject to the following conditions: 010 * 011 * The above copyright notice and this permission notice shall be included in 012 * all copies or substantial portions of the Software. 013 * 014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 020 * THE SOFTWARE. 021 */ 022package com.nexmo.client.voice.ncco; 023 024import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 025import com.fasterxml.jackson.annotation.JsonInclude; 026import com.fasterxml.jackson.annotation.JsonProperty; 027import com.nexmo.client.voice.PhoneEndpoint; 028import com.nexmo.client.voice.MachineDetection; 029 030@JsonInclude(value = JsonInclude.Include.NON_NULL) 031@JsonIgnoreProperties(ignoreUnknown = true) 032public class ConnectNcco implements Ncco { 033 private static final String ACTION = "connect"; 034 035 private PhoneEndpoint[] endpoint; 036 private String from = null; 037 private Integer timeout = null; 038 private Integer limit = null; 039 private MachineDetection machineDetection = null; 040 private String[] eventUrl = null; 041 private String eventMethod = null; 042 043 public ConnectNcco(@JsonProperty("endpoint") PhoneEndpoint[] endpoint) { 044 this.endpoint = endpoint; 045 } 046 047 public ConnectNcco(PhoneEndpoint endpoint) { 048 this(new PhoneEndpoint[]{endpoint}); 049 } 050 051 public ConnectNcco(String number) { 052 this(new PhoneEndpoint(number)); 053 } 054 055 public PhoneEndpoint[] getEndpoint() { 056 return endpoint; 057 } 058 059 public void setEndpoint(PhoneEndpoint endpoint) { 060 setEndpoint(new PhoneEndpoint[]{endpoint}); 061 } 062 063 @JsonProperty("endpoint") 064 public void setEndpoint(PhoneEndpoint[] endpoint) { 065 this.endpoint = endpoint; 066 } 067 068 public String getFrom() { 069 return from; 070 } 071 072 public void setFrom(String from) { 073 this.from = from; 074 } 075 076 public Integer getTimeout() { 077 return timeout; 078 } 079 080 public void setTimeout(Integer timeout) { 081 this.timeout = timeout; 082 } 083 084 public Integer getLimit() { 085 return limit; 086 } 087 088 public void setLimit(Integer limit) { 089 this.limit = limit; 090 } 091 092 public MachineDetection getMachineDetection() { 093 return machineDetection; 094 } 095 096 public void setMachineDetection(MachineDetection machineDetection) { 097 this.machineDetection = machineDetection; 098 } 099 100 public String[] getEventUrl() { 101 return eventUrl; 102 } 103 104 public void setEventUrl(String eventUrl) { 105 setEventUrl(new String[]{eventUrl}); 106 } 107 108 @JsonProperty("eventUrl") 109 public void setEventUrl(String[] eventUrl) { 110 this.eventUrl = eventUrl; 111 } 112 113 public String getEventMethod() { 114 return eventMethod; 115 } 116 117 public void setEventMethod(String eventMethod) { 118 this.eventMethod = eventMethod; 119 } 120 121 @Override 122 public String getAction() { 123 return ACTION; 124 } 125 126 @Override 127 public String toJson() { 128 return NccoSerializer.getInstance().serializeNcco(this); 129 } 130}