001package com.plivo.api.models.multipartycall;
002
003import com.fasterxml.jackson.databind.annotation.JsonSerialize;
004
005import com.plivo.api.exceptions.PlivoValidationException;
006import com.plivo.api.models.base.VoiceUpdater;
007import com.plivo.api.serializers.CommaDelimitedListSerializer;
008import com.plivo.api.serializers.DelimitedListSerializer;
009import com.plivo.api.serializers.MapToCommaListSerializer;
010import com.plivo.api.validators.*;
011import retrofit2.Call;
012
013import java.util.Arrays;
014import java.util.List;
015import java.util.Map;
016
017public class MultiPartyCallParticipantAdd extends VoiceUpdater<MultiPartyCallParticipantAddResponse> {
018
019  @OneOf(message = "should be one of [agent, customer, supervisor]", options = {"agent", "customer", "supervisor"})
020  private final String role;
021  private final String from;
022  @JsonSerialize(using = DelimitedListSerializer.class)
023  private final List<String> to;
024  private final String callUuid;
025  private String callerName;
026  @UrlValues
027  private String callStatusCallbackUrl;
028  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
029  private String callStatusCallbackMethod = "POST";
030  @JsonSerialize(using = MapToCommaListSerializer.class)
031  private Map<String, String> sipHeaders;
032  @OneOf(message = "should be one of [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, #, *]", options = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "#", "*"})
033  private String confirmKey;
034  @UrlValues
035  private String confirmKeySoundUrl;
036  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
037  private String confirmKeySoundMethod = "GET";
038  @UrlValues(message = "should be a valid URL or one of ['Real', 'None']", options = {"Real", "None"})
039  private String dialMusic = "Real";
040  @MultipleValidIntegers(message = "values must be either integer or string containing integers separated by delimiter '<' ")
041  private Object ringTimeout = 45;
042  @MultipleValidIntegers(message = "values must be either integer or string containing integers separated by delimiter '<' ")
043  private Object delayDial = 0;
044  @InRange(message = "must be in range [300-28800]", min = 300, max = 28800)
045  private Integer maxDuration = 14400;
046  @InRange(message = "must be in range [2-10]", min = 2, max = 10)
047  private Integer maxParticipants = 10;
048  @InRange(message = "must be in range [1-2]", min = 1, max = 2)
049  private Integer recordMinMemberCount = 1;
050  @UrlValues
051  private String waitMusicUrl;
052  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
053  private String waitMusicMethod = "GET";
054  @UrlValues
055  private String agentHoldMusicUrl;
056  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
057  private String agentHoldMusicMethod = "GET";
058  @UrlValues
059  private String customerHoldMusicUrl;
060  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
061  private String customerHoldMusicMethod = "GET";
062  @UrlValues
063  private String recordingCallbackUrl;
064  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
065  private String recordingCallbackMethod = "GET";
066  @UrlValues
067  private String statusCallbackUrl;
068  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
069  private String statusCallbackMethod = "POST";
070  @UrlValues
071  private String onExitActionUrl;
072  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
073  private String onExitActionMethod = "POST";
074  private Boolean record = false;
075  @OneOf(message = "should be one of [mp3, wav]", options = {"mp3", "wav"})
076  private String recordFileFormat = "mp3";
077  @JsonSerialize(using = CommaDelimitedListSerializer.class)
078  @MultiOf(message = "should be among [mpc-state-changes, participant-state-changes, participant-speak-events, participant-digit-input-events, add-participant-api-events]", options = {"mpc-state-changes", "participant-state-changes", "participant-speak-events", "participant-digit-input-events", "add-participant-api-events"})
079  private List<String> statusCallbackEvents = Arrays.asList("mpc-state-changes", "participant-state-changes");
080  private Boolean stayAlone = false;
081  private Boolean coachMode = true;
082  private Boolean mute = false;
083  private Boolean hold = false;
084  private Boolean startMpcOnEnter = true;
085  private Boolean endMpcOnExit = false;
086  private Boolean relayDtmfInputs = false;
087  @UrlValues(message = "should be a valid URL or one of ['beep:1', 'beep:2', 'none']", options = {"beep:1", "beep:2", "none"})
088  private String enterSound = "beep:1";
089  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
090  private String enterSoundMethod = "GET";
091  @UrlValues(message = "should be a valid URL or one of ['beep:1', 'beep:2', 'none']", options = {"beep:1", "beep:2", "none"})
092  private String exitSound = "beep:2";
093  @OneOf(message = "should be one of [GET, POST]", options = {"GET", "POST"})
094  private String exitSoundMethod = "GET";
095  @UrlValues
096  private String startRecordingAudio;
097  @OneOf(message = "should be one of['GET',POST']", options = {"GET", "POST"})
098  private String startRecordingAudioMethod = "GET";
099  @UrlValues
100  private String stopRecordingAudio;
101  @OneOf(message = "should be one of['GET',POST']", options = {"GET", "POST"})
102  private String stopRecordingAudioMethod = "GET";
103
104
105  public MultiPartyCallParticipantAdd(String mpcId, String role, String from, List<String> to) throws PlivoValidationException {
106    super(mpcId);
107    if (to.size() > 20) {
108      throw new PlivoValidationException("max of 20 destination numbers are allowed for bulk dialing");
109    }
110    if (to.size() > 1 && !role.equalsIgnoreCase(MultiPartyCallUtils.agent)) {
111      throw new PlivoValidationException("bulk dialing is allowed for role agent only");
112    }
113    this.role = role;
114    this.from = from;
115    this.to = to;
116    this.callUuid = null;
117    if (this.callerName == null) {
118      this.callerName = this.from;
119    }
120  }
121
122  public MultiPartyCallParticipantAdd(String mpcId, String role, String callUuid) {
123    super(mpcId);
124    this.role = role;
125    this.callUuid = callUuid;
126    this.from = null;
127    this.to = null;
128  }
129
130  public String role() {
131    return role;
132  }
133
134  public String from() {
135    return from;
136  }
137
138  public List<String> to() {
139    return to;
140  }
141
142  public String callUuid() {
143    return callUuid;
144  }
145
146  public String callerName() {
147    return callerName;
148  }
149
150  public String callStatusCallbackUrl() {
151    return callStatusCallbackUrl;
152  }
153
154  public String callStatusCallbackMethod() {
155    return callStatusCallbackMethod;
156  }
157
158  public Map<String, String> sipHeaders() {
159    return sipHeaders;
160  }
161
162  public String confirmKey() {
163    return confirmKey;
164  }
165
166  public String confirmKeySoundUrl() {
167    return confirmKeySoundUrl;
168  }
169
170  public String confirmKeySoundMethod() {
171    return confirmKeySoundMethod;
172  }
173
174  public String dialMusic() {
175    return dialMusic;
176  }
177
178  public Object ringTimeout() {
179    return ringTimeout;
180  }
181
182  public Object delayDial() {
183    return delayDial;
184  }
185
186  public Integer maxDuration() {
187    return maxDuration;
188  }
189
190  public Integer maxParticipants() {
191    return maxParticipants;
192  }
193
194  public Integer recordMinMemberCount() {
195    return recordMinMemberCount;
196  }
197
198  public String waitMusicUrl() {
199    return waitMusicUrl;
200  }
201
202  public String waitMusicMethod() {
203    return waitMusicMethod;
204  }
205
206  public String agentHoldMusicUrl() {
207    return agentHoldMusicUrl;
208  }
209
210  public String agentHoldMusicMethod() {
211    return agentHoldMusicMethod;
212  }
213
214  public String customerHoldMusicUrl() {
215    return customerHoldMusicUrl;
216  }
217
218  public String customerHoldMusicMethod() {
219    return customerHoldMusicMethod;
220  }
221
222  public String recordingCallbackUrl() {
223    return recordingCallbackUrl;
224  }
225
226  public String recordingCallbackMethod() {
227    return recordingCallbackMethod;
228  }
229
230  public String statusCallbackUrl() {
231    return statusCallbackUrl;
232  }
233
234  public String statusCallbackMethod() {
235    return statusCallbackMethod;
236  }
237
238  public String onExitActionUrl() {
239    return onExitActionUrl;
240  }
241
242  public String onExitActionMethod() {
243    return onExitActionMethod;
244  }
245
246  public Boolean record() {
247    return record;
248  }
249
250  public String recordFileFormat() {
251    return recordFileFormat;
252  }
253
254  public List<String> statusCallbackEvents() {
255    return statusCallbackEvents;
256  }
257
258  public Boolean stayAlone() {
259    return stayAlone;
260  }
261
262  public Boolean coachMode() {
263    return coachMode;
264  }
265
266  public Boolean mute() {
267    return mute;
268  }
269
270  public Boolean hold() {
271    return hold;
272  }
273
274  public Boolean startMpcOnEnter() {
275    return startMpcOnEnter;
276  }
277
278  public Boolean endMpcOnExit() {
279    return endMpcOnExit;
280  }
281
282  public Boolean relayDtmfInputs() {
283    return relayDtmfInputs;
284  }
285
286  public String enterSound() {
287    return enterSound;
288  }
289
290  public String enterSoundMethod() {
291    return enterSoundMethod;
292  }
293
294  public String exitSound() {
295    return exitSound;
296  }
297
298  public String exitSoundMethod() {
299    return exitSoundMethod;
300  }
301
302  public String startRecordingAudio() {
303    return startRecordingAudio;
304  }
305
306  public String startRecordingAudioMethod() {
307    return startRecordingAudioMethod;
308  }
309
310  public String stopRecordingAudio() {
311    return stopRecordingAudio;
312  }
313
314  public String stopRecordingAudioMethod() {
315    return stopRecordingAudioMethod;
316  }
317
318  public MultiPartyCallParticipantAdd callerName(String callerName) throws PlivoValidationException {
319    this.callerName = callerName;
320    if (callerName.length() > 50) {
321      throw new PlivoValidationException("CallerName Length must be in range [0,50]");
322    }
323    return this;
324  }
325
326  public MultiPartyCallParticipantAdd callStatusCallbackUrl(String callStatusCallbackUrl) {
327    this.callStatusCallbackUrl = callStatusCallbackUrl;
328    return this;
329  }
330
331  public MultiPartyCallParticipantAdd callStatusCallbackMethod(String callStatusCallbackMethod) {
332    this.callStatusCallbackMethod = callStatusCallbackMethod;
333    return this;
334  }
335
336  public MultiPartyCallParticipantAdd sipHeaders(Map<String, String> sipHeaders) {
337    this.sipHeaders = sipHeaders;
338    return this;
339  }
340
341  public MultiPartyCallParticipantAdd confirmKey(String confirmKey) {
342    this.confirmKey = confirmKey;
343    return this;
344  }
345
346  public MultiPartyCallParticipantAdd confirmKeySoundUrl(String confirmKeySoundUrl) {
347    this.confirmKeySoundUrl = confirmKeySoundUrl;
348    return this;
349  }
350
351  public MultiPartyCallParticipantAdd confirmKeySoundMethod(String confirmKeySoundMethod) {
352    this.confirmKeySoundMethod = confirmKeySoundMethod;
353    return this;
354  }
355
356  public MultiPartyCallParticipantAdd dialMusic(String dialMusic) {
357    this.dialMusic = dialMusic;
358    return this;
359  }
360
361  public MultiPartyCallParticipantAdd ringTimeout(Object ringTimeout) {
362    this.ringTimeout = ringTimeout;
363    return this;
364  }
365
366  public MultiPartyCallParticipantAdd delayDial(Object delayDial) {
367    this.delayDial = delayDial;
368    return this;
369  }
370
371  public MultiPartyCallParticipantAdd maxDuration(Integer maxDuration) {
372    this.maxDuration = maxDuration;
373    return this;
374  }
375
376  public MultiPartyCallParticipantAdd maxParticipants(Integer maxParticipants) {
377    this.maxParticipants = maxParticipants;
378    return this;
379  }
380
381  public MultiPartyCallParticipantAdd recordMinMemberCount(Integer recordMinMemberCount) {
382    this.recordMinMemberCount = recordMinMemberCount;
383    return this;
384  }
385
386  public MultiPartyCallParticipantAdd waitMusicUrl(String waitMusicUrl) {
387    this.waitMusicUrl = waitMusicUrl;
388    return this;
389  }
390
391  public MultiPartyCallParticipantAdd waitMusicMethod(String waitMusicMethod) {
392    this.waitMusicMethod = waitMusicMethod;
393    return this;
394  }
395
396  public MultiPartyCallParticipantAdd agentHoldMusicUrl(String agentHoldMusicUrl) {
397    this.agentHoldMusicUrl = agentHoldMusicUrl;
398    return this;
399  }
400
401  public MultiPartyCallParticipantAdd agentHoldMusicMethod(String agentHoldMusicMethod) {
402    this.agentHoldMusicMethod = agentHoldMusicMethod;
403    return this;
404  }
405
406  public MultiPartyCallParticipantAdd customerHoldMusicUrl(String customerHoldMusicUrl) {
407    this.customerHoldMusicUrl = customerHoldMusicUrl;
408    return this;
409  }
410
411  public MultiPartyCallParticipantAdd customerHoldMusicMethod(String customerHoldMusicMethod) {
412    this.customerHoldMusicMethod = customerHoldMusicMethod;
413    return this;
414  }
415
416  public MultiPartyCallParticipantAdd recordingCallbackUrl(String recordingCallbackUrl) {
417    this.recordingCallbackUrl = recordingCallbackUrl;
418    return this;
419  }
420
421  public MultiPartyCallParticipantAdd recordingCallbackMethod(String recordingCallbackMethod) {
422    this.recordingCallbackMethod = recordingCallbackMethod;
423    return this;
424  }
425
426  public MultiPartyCallParticipantAdd statusCallbackUrl(String statusCallbackUrl) {
427    this.statusCallbackUrl = statusCallbackUrl;
428    return this;
429  }
430
431  public MultiPartyCallParticipantAdd statusCallbackMethod(String statusCallbackMethod) {
432    this.statusCallbackMethod = statusCallbackMethod;
433    return this;
434  }
435
436  public MultiPartyCallParticipantAdd onExitActionUrl(String onExitActionUrl) {
437    this.onExitActionUrl = onExitActionUrl;
438    return this;
439  }
440
441  public MultiPartyCallParticipantAdd onExitActionMethod(String onExitActionMethod) {
442    this.onExitActionMethod = onExitActionMethod;
443    return this;
444  }
445
446  public MultiPartyCallParticipantAdd record(Boolean record) {
447    this.record = record;
448    return this;
449  }
450
451  public MultiPartyCallParticipantAdd recordFileFormat(String recordFileFormat) {
452    this.recordFileFormat = recordFileFormat;
453    return this;
454  }
455
456  public MultiPartyCallParticipantAdd statusCallbackEvents(List<String> statusCallbackEvents) {
457    this.statusCallbackEvents = statusCallbackEvents;
458    return this;
459  }
460
461  public MultiPartyCallParticipantAdd stayAlone(Boolean stayAlone) {
462    this.stayAlone = stayAlone;
463    return this;
464  }
465
466  public MultiPartyCallParticipantAdd coachMode(Boolean coachMode) {
467    this.coachMode = coachMode;
468    return this;
469  }
470
471  public MultiPartyCallParticipantAdd mute(Boolean mute) {
472    this.mute = mute;
473    return this;
474  }
475
476  public MultiPartyCallParticipantAdd hold(Boolean hold) {
477    this.hold = hold;
478    return this;
479  }
480
481  public MultiPartyCallParticipantAdd startMpcOnEnter(Boolean startMpcOnEnter) {
482    this.startMpcOnEnter = startMpcOnEnter;
483    return this;
484  }
485
486  public MultiPartyCallParticipantAdd endMpcOnExit(Boolean endMpcOnExit) {
487    this.endMpcOnExit = endMpcOnExit;
488    return this;
489  }
490
491  public MultiPartyCallParticipantAdd relayDtmfInputs(Boolean relayDtmfInputs) {
492    this.relayDtmfInputs = relayDtmfInputs;
493    return this;
494  }
495
496  public MultiPartyCallParticipantAdd enterSound(String enterSound) {
497    this.enterSound = enterSound;
498    return this;
499  }
500
501  public MultiPartyCallParticipantAdd enterSoundMethod(String enterSoundMethod) {
502    this.enterSoundMethod = enterSoundMethod;
503    return this;
504  }
505
506  public MultiPartyCallParticipantAdd exitSound(String exitSound) {
507    this.exitSound = exitSound;
508    return this;
509  }
510
511  public MultiPartyCallParticipantAdd exitSoundMethod(String exitSoundMethod) {
512    this.exitSoundMethod = exitSoundMethod;
513    return this;
514  }
515
516  public MultiPartyCallParticipantAdd startRecordingAudio(String startRecordingAudio) {
517    this.startRecordingAudio = startRecordingAudio;
518    return this;
519  }
520
521  public MultiPartyCallParticipantAdd startRecordingAudioMethod(String startRecordingAudioMethod) {
522    this.startRecordingAudioMethod = startRecordingAudioMethod;
523    return this;
524  }
525
526  public MultiPartyCallParticipantAdd stopRecordingAudio(String stopRecordingAudio) {
527    this.stopRecordingAudio= stopRecordingAudio;
528    return this;
529  }
530
531  public MultiPartyCallParticipantAdd stopRecordingAudioMethod(String stopRecordingAudioMethod) {
532    this.stopRecordingAudioMethod = stopRecordingAudioMethod;
533    return this;
534  }
535
536  @Override
537  protected Call<MultiPartyCallParticipantAddResponse> obtainCall() throws PlivoValidationException {
538    Validate.check(this);
539    return client().getVoiceApiService().mpcAddParticipant(client().getAuthId(), id, this);
540  }
541
542  @Override
543  protected Call<MultiPartyCallParticipantAddResponse> obtainFallback1Call() throws PlivoValidationException {
544    Validate.check(this);
545    return client().getVoiceFallback1Service().mpcAddParticipant(client().getAuthId(), id, this);
546  }
547
548  @Override
549  protected Call<MultiPartyCallParticipantAddResponse> obtainFallback2Call() throws PlivoValidationException {
550    Validate.check(this);
551    return client().getVoiceFallback2Service().mpcAddParticipant(client().getAuthId(), id, this);
552  }
553}