plivo 4.18.0 → 4.22.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,633 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+ class MultiPartyCall < Base::Resource
5
+ def initialize(client, options = nil)
6
+ @_name = 'MultiPartyCall'
7
+ @_identifier_string = 'mpc_uuid'
8
+ super
9
+ @_is_voice_request = true
10
+ if options.key? :multi_party_prefix
11
+ @id = options[:multi_party_prefix] + '_' + @id
12
+ else
13
+ @id = 'uuid_' + @id
14
+ end
15
+ configure_resource_uri
16
+ end
17
+
18
+ def get
19
+ perform_action(nil,'GET',nil,true)
20
+ end
21
+
22
+ def add_participant(role,
23
+ from=nil,
24
+ to=nil,
25
+ call_uuid=nil,
26
+ caller_name=nil,
27
+ call_status_callback_url=nil,
28
+ call_status_callback_method='POST',
29
+ sip_headers=nil,
30
+ confirm_key=nil,
31
+ confirm_key_sound_url=nil,
32
+ confirm_key_sound_method='GET',
33
+ dial_music='Real',
34
+ ring_timeout=45,
35
+ delay_dial=0,
36
+ max_duration=14400,
37
+ max_participants=10,
38
+ wait_music_url=nil,
39
+ wait_music_method='GET',
40
+ agent_hold_music_url=nil,
41
+ agent_hold_music_method='GET',
42
+ customer_hold_music_url=nil,
43
+ customer_hold_music_method='GET',
44
+ recording_callback_url=nil,
45
+ recording_callback_method='GET',
46
+ status_callback_url=nil,
47
+ status_callback_method='GET',
48
+ on_exit_action_url=nil,
49
+ on_exit_action_method='POST',
50
+ record=false,
51
+ record_file_format='mp3',
52
+ status_callback_events='mpc-state-changes,participant-state-changes',
53
+ stay_alone=false,
54
+ coach_mode=true,
55
+ mute=false,
56
+ hold=false,
57
+ start_mpc_on_enter=false,
58
+ end_mpc_on_exit=false,
59
+ relay_dtmf_inputs=false,
60
+ enter_sound='beep:1',
61
+ enter_sound_method='GET',
62
+ exit_sound='beep:2',
63
+ exit_sound_method='GET',
64
+ start_recording_audio=nil,
65
+ start_recording_audio_method='GET',
66
+ stop_recording_audio=nil,
67
+ stop_recording_audio_method='GET')
68
+ if (from and to) and call_uuid
69
+ raise_invalid_request('cannot specify call_uuid when (from, to) is provided')
70
+ end
71
+ if not from and not to and not call_uuid
72
+ raise_invalid_request('specify either call_uuid or (from, to)')
73
+ end
74
+ if call_uuid.nil? and (not from or not to)
75
+ raise_invalid_request('specify (from, to) when not adding an existing call_uuid to multi party participant')
76
+ end
77
+
78
+ valid_param?(:role, role.downcase, String, true, %w[agent supervisor customer])
79
+ valid_param?(:from, from, String, false ) unless from.nil?
80
+ valid_param?(:to, to, String, false ) unless to.nil?
81
+ valid_multiple_destination_nos?(:to, to, role: role, delimiter: '<', agent_limit: 20) unless to.nil?
82
+ valid_param?(:call_uuid, call_uuid, String, false ) unless call_uuid.nil?
83
+ valid_param?(:caller_name, caller_name, String, false) unless caller_name.nil?
84
+ valid_range?(:caller_name, caller_name.length, false, 0, 50) unless caller_name.nil?
85
+ valid_url?(:call_status_callback_url, call_status_callback_url, false) unless call_status_callback_url.nil?
86
+ valid_param?(:call_status_callback_method, call_status_callback_method.upcase, String, false, %w[GET POST])
87
+ valid_param?(:sip_headers, sip_headers, String, false) unless sip_headers.nil?
88
+ valid_param?(:confirm_key, confirm_key, String, false , %w[0 1 2 3 4 5 6 7 8 9 # *]) unless confirm_key.nil?
89
+ valid_url?(:confirm_key_sound_url, confirm_key_sound_url, false) unless confirm_key_sound_url.nil?
90
+ valid_param?(:confirm_key_sound_method, confirm_key_sound_method.upcase, String, false, %w[GET POST])
91
+ is_one_among_string_url?(:dial_music, dial_music, false, %w[real none])
92
+ valid_param?(:ring_timeout, ring_timeout, [String,Integer], false)
93
+ valid_multiple_destination_integers?(:ring_timeout, ring_timeout)
94
+ valid_param?(:delay_dial, delay_dial, [String,Integer], false)
95
+ valid_multiple_destination_integers?(:delay_dial, delay_dial)
96
+ valid_range?(:max_duration, max_duration, false, 300, 28800)
97
+ valid_range?(:max_participants, max_participants, false, 2, 10)
98
+ valid_url?(:wait_music_url, wait_music_url, false ) unless wait_music_url.nil?
99
+ valid_param?(:wait_music_method, wait_music_method.upcase, String, false , %w[GET POST])
100
+ valid_url?(:agent_hold_music_url, agent_hold_music_url, false) unless agent_hold_music_url.nil?
101
+ valid_param?(:agent_hold_music_method, agent_hold_music_method.upcase, String, false , %w[GET POST])
102
+ valid_url?(:customer_hold_music_url, customer_hold_music_url, false) unless customer_hold_music_url.nil?
103
+ valid_param?(:customer_hold_music_method, customer_hold_music_method.upcase, String, false, %w[GET POST])
104
+ valid_url?(:recording_callback_url, recording_callback_url, false) unless recording_callback_url.nil?
105
+ valid_param?(:recording_callback_method, recording_callback_method.upcase, String, false, %w[GET POST])
106
+ valid_url?(:status_callback_url, status_callback_url, false) unless status_callback_url.nil?
107
+ valid_param?(:status_callback_method, status_callback_method.upcase, String, false, %w[GET POST])
108
+ valid_url?(:on_exit_action_url, on_exit_action_url, false ) unless on_exit_action_url.nil?
109
+ valid_param?(:on_exit_action_method, on_exit_action_method.upcase, String, false, %w[GET POST])
110
+ valid_param?(:record, record, [TrueClass, FalseClass], false )
111
+ valid_param?(:record_file_format, record_file_format.downcase, String, false, %w[mp3 wav])
112
+ multi_valid_param?(:status_callback_events, status_callback_events.downcase, String, false, %w[mpc-state-changes participant-state-changes participant-speak-events participant-digit-input-events add-participant-api-events], true, ',')
113
+ valid_param?(:stay_alone, stay_alone, [TrueClass, FalseClass], false)
114
+ valid_param?(:coach_mode, coach_mode, [TrueClass, FalseClass], false)
115
+ valid_param?(:mute, mute, [TrueClass, FalseClass],false)
116
+ valid_param?(:hold, hold, [TrueClass, FalseClass], false)
117
+ valid_param?(:start_mpc_on_enter, start_mpc_on_enter, [TrueClass, FalseClass], false)
118
+ valid_param?(:end_mpc_on_exit, end_mpc_on_exit, [TrueClass, FalseClass], false)
119
+ valid_param?(:relay_dtmf_inputs, relay_dtmf_inputs, [TrueClass, FalseClass], false)
120
+ is_one_among_string_url?(:enter_sound, enter_sound, false, %w[beep:1 beep:2 none])
121
+ valid_param?(:enter_sound_method, enter_sound_method.upcase, String, false, %w[GET POST])
122
+ is_one_among_string_url?(:exit_sound, exit_sound, false , %w[beep:1 beep:2 none])
123
+ valid_param?(:exit_sound_method, exit_sound_method.upcase, String, false, %w[GET POST])
124
+ valid_param?(:start_recording_audio_method, start_recording_audio_method.upcase, String, false, %w[GET POST])
125
+ valid_url?(:start_recording_audio, start_recording_audio, false ) unless start_recording_audio.nil?
126
+ valid_param?(:stop_recording_audio_method, stop_recording_audio_method.upcase, String, false, %w[GET POST])
127
+ valid_url?(:stop_recording_audio, stop_recording_audio, false ) unless stop_recording_audio.nil?
128
+ if (to!=nil) && (ring_timeout.is_a?(String)) && (to.split('<').size < ring_timeout.split('<').size)
129
+ raise_invalid_request("RingTimeout:number of ring_timout(s) should be same as number of destination(s)")
130
+ end
131
+
132
+ if (to!=nil) && (delay_dial.is_a?(String)) && (to.split('<').size < delay_dial.split('<').size)
133
+ raise_invalid_request("Delaydial : number of delay_dial(s) should be same as number of destination(s)")
134
+ end
135
+
136
+ params = {}
137
+ params[:role] = role unless role.nil?
138
+ params[:from] = from unless from.nil?
139
+ params[:to] = to unless to.nil?
140
+ params[:call_uuid] = call_uuid unless call_uuid.nil?
141
+ params[:caller_name] = caller_name || from
142
+ params[:call_status_callback_url] = call_status_callback_url unless call_status_callback_url.nil?
143
+ params[:call_status_callback_method] = call_status_callback_method.upcase unless call_status_callback_method.nil?
144
+ params[:sip_headers] = sip_headers unless sip_headers.nil?
145
+ params[:confirm_key] = confirm_key unless confirm_key.nil?
146
+ params[:confirm_key_sound_url] = confirm_key_sound_url unless confirm_key_sound_url.nil?
147
+ params[:confirm_key_sound_method] = confirm_key_sound_method.upcase unless confirm_key_sound_method.nil?
148
+ params[:dial_music] = dial_music unless dial_music.nil?
149
+ params[:ring_timeout] = ring_timeout unless ring_timeout.nil?
150
+ params[:delay_dial] = delay_dial unless delay_dial.nil?
151
+ params[:max_duration] = max_duration unless max_duration.nil?
152
+ params[:max_participants] = max_participants unless max_participants.nil?
153
+ params[:wait_music_url] = wait_music_url unless wait_music_url.nil?
154
+ params[:wait_music_method] = wait_music_method.upcase unless wait_music_method.nil?
155
+ params[:agent_hold_music_url] = agent_hold_music_url unless agent_hold_music_url.nil?
156
+ params[:agent_hold_music_method] = agent_hold_music_method.upcase unless agent_hold_music_method.nil?
157
+ params[:customer_hold_music_url] = customer_hold_music_url unless customer_hold_music_url.nil?
158
+ params[:customer_hold_music_method] = customer_hold_music_method.upcase unless customer_hold_music_method.nil?
159
+ params[:recording_callback_url] = recording_callback_url unless recording_callback_url.nil?
160
+ params[:recording_callback_method] = recording_callback_method.upcase unless recording_callback_method.nil?
161
+ params[:status_callback_url] = status_callback_url unless status_callback_url.nil?
162
+ params[:status_callback_method] = status_callback_method.upcase unless status_callback_method.nil?
163
+ params[:on_exit_action_url] = on_exit_action_url unless on_exit_action_url.nil?
164
+ params[:on_exit_action_method] = on_exit_action_method.upcase unless on_exit_action_method.nil?
165
+ params[:record] = record unless record.nil?
166
+ params[:record_file_format] = record_file_format.downcase unless record_file_format.nil?
167
+ params[:status_callback_events] = status_callback_events.downcase unless status_callback_events.nil?
168
+ params[:stay_alone] = stay_alone unless stay_alone.nil?
169
+ params[:coach_mode] = coach_mode unless coach_mode.nil?
170
+ params[:mute] = mute unless mute.nil?
171
+ params[:hold] = hold unless hold.nil?
172
+ params[:start_mpc_on_enter] = start_mpc_on_enter unless start_mpc_on_enter.nil?
173
+ params[:end_mpc_on_exit] = end_mpc_on_exit unless end_mpc_on_exit.nil?
174
+ params[:relay_dtmf_inputs] = relay_dtmf_inputs unless relay_dtmf_inputs.nil?
175
+ params[:enter_sound] = enter_sound unless enter_sound.nil?
176
+ params[:enter_sound_method] = enter_sound_method.upcase unless exit_sound_method.nil?
177
+ params[:exit_sound] = exit_sound unless exit_sound.nil?
178
+ params[:exit_sound_method] = exit_sound_method.upcase unless exit_sound_method.nil?
179
+ params[:start_recording_audio] = start_recording_audio unless start_recording_audio.nil?
180
+ params[:start_recording_audio_method] = start_recording_audio_method.upcase unless start_recording_audio_method.nil?
181
+ params[:stop_recording_audio] = stop_recording_audio unless stop_recording_audio.nil?
182
+ params[:stop_recording_audio_method] = stop_recording_audio_method.upcase unless stop_recording_audio_method.nil?
183
+ perform_action_apiresponse('Participant', 'POST', params, true )
184
+ end
185
+
186
+ def start
187
+ perform_action_apiresponse(nil, 'POST', Hash['status' => 'active'], true)
188
+ end
189
+
190
+ def stop
191
+ perform_action_apiresponse(nil, 'DELETE', nil, true)
192
+ end
193
+
194
+ def start_recording(file_format = 'mp3', status_callback_url = nil, status_callback_method='POST')
195
+ valid_param?(:file_format, file_format, String, false , %w[mp3 wav])
196
+ valid_url?(:status_callback_url, status_callback_url, false) unless status_callback_url.nil?
197
+ valid_param?(:status_callback_method, status_callback_method.upcase,String, false, %w[GET POST])
198
+
199
+ params = {}
200
+ params[:file_format] = file_format.downcase unless file_format.nil?
201
+ params[:status_callback_url] = status_callback_url unless status_callback_url.nil?
202
+ params[:status_callback_method] = status_callback_method.upcase unless status_callback_method.nil?
203
+
204
+ perform_action_apiresponse('Record', 'POST', params, true)
205
+ end
206
+
207
+ def stop_recording
208
+ perform_action_apiresponse('Record', 'DELETE')
209
+ end
210
+
211
+ def pause_recording
212
+ perform_action_apiresponse('Record/Pause', 'POST')
213
+ end
214
+
215
+ def resume_recording
216
+ perform_action_apiresponse('Record/Resume', 'POST')
217
+ end
218
+
219
+ def start_participant_recording(member_id, file_format='mp3', status_callback_url=nil, status_callback_method='POST')
220
+ valid_param?(:member_id, member_id, [String, Integer], true)
221
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).start_participant_recording(file_format, status_callback_url, status_callback_method)
222
+ end
223
+
224
+ def stop_participant_recording(member_id)
225
+ valid_param?(:member_id, member_id, [String, Integer], true)
226
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).stop_participant_recording
227
+ end
228
+
229
+ def pause_participant_recording(member_id)
230
+ valid_param?(:member_id, member_id, [String, Integer], true)
231
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).pause_participant_recording
232
+ end
233
+
234
+ def resume_participant_recording(member_id)
235
+ valid_param?(:member_id, member_id, [String, Integer], true)
236
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).resume_participant_recording
237
+ end
238
+
239
+ def list_participants(call_uuid = nil )
240
+ valid_param?(:call_uuid, call_uuid, String, false) unless call_uuid.nil?
241
+ params = {}
242
+ params[:call_uuid] = call_uuid unless call_uuid.nil?
243
+ perform_action('Participant', 'GET', params, true)
244
+ end
245
+
246
+ def update_participant(member_id, coach_mode = nil, mute = nil , hold = nil)
247
+ valid_param?(:member_id, member_id, [String, Integer], true)
248
+ MultiPartyCallParticipant.new(@_client, resource_id: @id, member_id: member_id).update_participant(coach_mode, mute, hold)
249
+ end
250
+
251
+ def kick_participant(member_id)
252
+ valid_param?(:member_id, member_id, [String, Integer], true)
253
+ MultiPartyCallParticipant.new(@_client, resource_id: @id, member_id: member_id).kick_participant
254
+ end
255
+
256
+ def get_participant(member_id)
257
+ valid_param?(:member_id, member_id, [String, Integer], true)
258
+ MultiPartyCallParticipant.new(@_client,resource_id: @id, member_id: member_id).get_participant
259
+ end
260
+
261
+ def start_play_audio(member_id, url)
262
+ valid_param?(:member_id, member_id, [String, Integer], true)
263
+ valid_url?(:url, url, true)
264
+ MultiPartyCallMember.new(@_client, resource_id: @id, member_id: member_id).start_play_audio(url)
265
+ end
266
+
267
+ def stop_play_audio(member_id)
268
+ valid_param?(:member_id, member_id, [String, Integer], true)
269
+ MultiPartyCallMember.new(@_client, resource_id: @id, member_id: member_id).stop_play_audio
270
+ end
271
+ end
272
+
273
+ class MultiPartyCallParticipant < Base::SecondaryResource
274
+ def initialize(client, options = nil)
275
+ @_name = 'MultiPartyCall'
276
+ @_identifier_string = 'mpc_uuid'
277
+ @_secondary_name = 'Participant'
278
+ @_secondary_identifier_string = 'member_id'
279
+ super
280
+ @_is_voice_request = true
281
+ if options.key? :multi_party_prefix
282
+ @id = options[:multi_party_prefix] + '_' + @id
283
+ elsif @id.split('_').size > 1
284
+ nil
285
+ else
286
+ @id = 'uuid_' + @id
287
+ end
288
+ configure_secondary_resource_uri
289
+ end
290
+
291
+ def start_participant_recording(file_format = 'mp3', status_callback_url = nil, status_callback_method='POST')
292
+ valid_param?(:file_format, file_format, String, false , %w[mp3 wav])
293
+ valid_url?(:status_callback_url, status_callback_url, false) unless status_callback_url.nil?
294
+ valid_param?(:status_callback_method, status_callback_method.upcase,String, false, %w[GET POST])
295
+
296
+ params = {}
297
+ params[:file_format] = file_format.downcase unless file_format.nil?
298
+ params[:status_callback_url] = status_callback_url unless status_callback_url.nil?
299
+ params[:status_callback_method] = status_callback_method.upcase unless status_callback_method.nil?
300
+
301
+ perform_action_apiresponse('Record', 'POST', params, true)
302
+ end
303
+
304
+ def stop_participant_recording
305
+ perform_action_apiresponse('Record', 'DELETE')
306
+ end
307
+
308
+ def pause_participant_recording
309
+ perform_action_apiresponse('Record/Pause', 'POST')
310
+ end
311
+
312
+ def resume_participant_recording
313
+ perform_action_apiresponse('Record/Resume', 'POST')
314
+ end
315
+
316
+ def update_participant(coach_mode = nil, mute= nil, hold = nil)
317
+ valid_param?(:coach_mode, coach_mode, [TrueClass, FalseClass], false) unless coach_mode.nil?
318
+ valid_param?(:mute, mute, [TrueClass, FalseClass], false) unless mute.nil?
319
+ valid_param?(:hold, hold, [TrueClass, FalseClass], false) unless hold.nil?
320
+ params = {}
321
+ params[:coach_mode] = coach_mode unless coach_mode.nil?
322
+ params[:mute] = mute unless mute.nil?
323
+ params[:hold] = hold unless hold.nil?
324
+ perform_action_apiresponse(nil, 'POST', params, true )
325
+ end
326
+
327
+ def kick_participant
328
+ perform_action_apiresponse(nil, 'DELETE', nil, true)
329
+ end
330
+
331
+ def get_participant
332
+ perform_action_apiresponse(nil,'GET',nil,false)
333
+ end
334
+ end
335
+
336
+ class MultiPartyCallMember < Base::SecondaryResource
337
+ def initialize(client, options = nil)
338
+ @_name = 'MultiPartyCall'
339
+ @_identifier_string = 'mpc_uuid'
340
+ @_secondary_name = 'Member'
341
+ @_secondary_identifier_string = 'member_id'
342
+ super
343
+ @_is_voice_request = true
344
+ if options.key? :multi_party_prefix
345
+ @id = options[:multi_party_prefix] + '_' + @id
346
+ elsif @id.split('_').size > 1
347
+ nil
348
+ else
349
+ @id = 'uuid_' + @id
350
+ end
351
+ configure_secondary_resource_uri
352
+ end
353
+
354
+ def start_play_audio(url)
355
+ valid_url?(:url, url, true)
356
+ params = {}
357
+ params[:url] = url unless url.nil?
358
+ perform_action_apiresponse('Play', 'POST', params, true)
359
+ end
360
+
361
+ def stop_play_audio
362
+ perform_action_apiresponse('Play', 'DELETE')
363
+ end
364
+ end
365
+
366
+ class MultiPartyCallInterface < Base::ResourceInterface
367
+ def initialize(client, resource_list_json = nil)
368
+ @_name = 'MultiPartyCall'
369
+ @_resource_type = MultiPartyCall
370
+ @_identifier_string = 'mpc_uuid'
371
+ super
372
+ @_is_voice_request = true
373
+ end
374
+
375
+ def make_mpc_id(uuid=nil, friendly_name=nil)
376
+ if not uuid and not friendly_name
377
+ raise_invalid_request('specify either multi party call friendly name or uuid')
378
+ end
379
+ if uuid and friendly_name
380
+ raise_invalid_request('cannot specify both multi party call friendly name or uuid')
381
+ end
382
+ if uuid
383
+ identifier = ['uuid', uuid]
384
+ else
385
+ identifier = ['name', friendly_name]
386
+ end
387
+ return identifier
388
+ end
389
+
390
+ def list(options={})
391
+ valid_param?(:options, options, Hash, false)
392
+ valid_subaccount?(options[:sub_account], true) unless options[:sub_account].nil?
393
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
394
+ valid_param?(:status, options[:status].downcase, String, false, %w[initialized active ended]) unless options[:status].nil?
395
+ valid_param?(:termination_cause_code, options[:termination_cause_code], Integer, false) unless options[:termination_cause_code].nil?
396
+ valid_date_format?(:end_time__gt, options[:end_time__gt], false ) unless options[:end_time__gt].nil?
397
+ valid_date_format?(:end_time__gte, options[:end_time__gte], false ) unless options[:end_time__gte].nil?
398
+ valid_date_format?(:end_time__lt, options[:end_time__lt], String) unless options[:end_time__lt].nil?
399
+ valid_date_format?(:end_time__lte, options[:end_time__lte], false) unless options[:end_time__lte].nil?
400
+ valid_date_format?(:creation_time__gt, options[:creation_time__gt], false) unless options[:creation_time__gt].nil?
401
+ valid_date_format?(:creation_time__gte, options[:creation_time__gte], false) unless options[:creation_time__gte].nil?
402
+ valid_date_format?(:creation_time__lt, options[:creation_time__lt], false) unless options[:creation_time__lt].nil?
403
+ valid_date_format?(:creation_time__lte, options[:creation_time__lte], false) unless options[:creation_time__lte].nil?
404
+ valid_range?(:limit, options[:limit], false, 1, 20)
405
+ valid_range?(:offset, options[:offset], false, 0)
406
+ perform_action(nil ,'GET', options ,true )
407
+ end
408
+
409
+ def get(options = {})
410
+ valid_param?(:options, options, Hash, false)
411
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
412
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
413
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
414
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).get
415
+ end
416
+
417
+ def add_participant(options = {})
418
+ valid_param?(:options, options, Hash, false)
419
+ if not options[:role ]
420
+ raise_invalid_request("Role is mandatory")
421
+ end
422
+ options[:call_status_callback_method] = 'POST' unless options.key?(:call_status_callback_method)
423
+ options[:confirm_key_sound_method] = 'GET' unless options.key?(:confirm_key_sound_method)
424
+ options[:dial_music] = 'Real' unless options.key?(:dial_music)
425
+ options[:ring_timeout] = 45 unless options.key?(:ring_timeout)
426
+ options[:delay_dial] = 0 unless options.key?(:delay_dial)
427
+ options[:max_duration] = 14400 unless options.key?(:max_duration)
428
+ options[:max_participants] = 10 unless options.key?(:max_participants)
429
+ options[:wait_music_method] = 'GET' unless options.key?(:wait_music_method)
430
+ options[:agent_hold_music_method] = 'GET' unless options.key?(:agent_hold_music_method)
431
+ options[:customer_hold_music_method] = 'GET' unless options.key?(:customer_hold_music_method)
432
+ options[:recording_callback_method] ='GET' unless options.key?(:recording_callback_method)
433
+ options[:status_callback_method] = 'GET' unless options.key?(:status_callback_method)
434
+ options[:on_exit_action_method] = 'POST' unless options.key?(:on_exit_action_method)
435
+ options[:record] = false unless options.key?(:record)
436
+ options[:record_file_format] = 'mp3' unless options.key?(:record_file_format)
437
+ options[:status_callback_events] = 'mpc-state-changes,participant-state-changes' unless options.key?(:status_callback_events)
438
+ options[:stay_alone] = false unless options.key?(:stay_alone)
439
+ options[:coach_mode] = true unless options.key?(:coach_mode)
440
+ options[:mute] = false unless options.key?(:mute)
441
+ options[:hold] = false unless options.key?(:hold)
442
+ options[:start_mpc_on_enter] = true unless options.key?(:start_mpc_on_enter)
443
+ options[:end_mpc_on_exit] = false unless options.key?(:end_mpc_on_exit)
444
+ options[:relay_dtmf_inputs] = false unless options.key?(:relay_dtmf_inputs)
445
+ options[:enter_sound] = 'beep:1' unless options.key?(:enter_sound)
446
+ options[:enter_sound_method] = 'GET' unless options.key?(:enter_sound_method)
447
+ options[:exit_sound] = 'beep:2' unless options.key?(:exit_sound)
448
+ options[:exit_sound_method] = 'GET' unless options.key?(:exit_sound_method)
449
+ options[:start_recording_audio_method] = 'GET' unless options.key?(:start_recording_audio_method)
450
+ options[:stop_recording_audio_method] = 'GET' unless options.key?(:stop_recording_audio_method)
451
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
452
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
453
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
454
+
455
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).add_participant(options[:role],options[:from],options[:to],options[:call_uuid],options[:caller_name],options[:call_status_callback_url],options[:call_status_callback_method],options[:sip_headers],options[:confirm_key],
456
+ options[:confirm_key_sound_url],options[:confirm_key_sound_method],options[:dial_music],options[:ring_timeout],options[:delay_dial],options[:max_duration], options[:max_participants],options[:wait_music_url],
457
+ options[:wait_music_method],options[:agent_hold_music_url],options[:agent_hold_music_method],options[:customer_hold_music_url],options[:customer_hold_music_method],
458
+ options[:recording_callback_url],options[:recording_callback_method],options[:status_callback_url],options[:status_callback_method],options[:on_exit_action_url], options[:on_exit_action_method],
459
+ options[:record],options[:record_file_format],options[:status_callback_events],options[:stay_alone], options[:coach_mode],options[:mute],options[:hold],options[:start_mpc_on_enter],options[:end_mpc_on_exit],
460
+ options[:relay_dtmf_inputs],options[:enter_sound],options[:enter_sound_method],options[:exit_sound],options[:exit_sound_method], options[:start_recording_audio], options[:start_recording_audio_method],
461
+ options[:stop_recording_audio], options[:stop_recording_audio_method])
462
+ end
463
+
464
+ def start(options = {})
465
+ valid_param?(:options, options, Hash, false)
466
+ valid_param?(:uuid, options[:uuid], String, false)
467
+ valid_param?(:friendly_name, options[:friendly_name], String, false)
468
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
469
+ MultiPartyCall.new(@_client,resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).start
470
+ end
471
+
472
+ def stop(options = {})
473
+ valid_param?(:options, options, Hash, false)
474
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
475
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
476
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
477
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).stop
478
+ end
479
+
480
+ def start_recording(options = {})
481
+ valid_param?(:options, options, Hash, false)
482
+ options[:file_format] = 'mp3' unless options.key?(:file_format)
483
+ options[:status_callback_method] = 'POST' unless options.key?(:status_callback_method)
484
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
485
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
486
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
487
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).start_recording(options[:file_format], options[:status_callback_url], options[:status_callback_method])
488
+ end
489
+
490
+ def stop_recording(options = {})
491
+ valid_param?(:options, options, Hash, false)
492
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
493
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
494
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
495
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).stop_recording
496
+ end
497
+
498
+ def pause_recording(options = {})
499
+ valid_param?(:options, options, Hash, false)
500
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
501
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
502
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
503
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).pause_recording
504
+ end
505
+
506
+ def resume_recording(options = {})
507
+ valid_param?(:options, options, Hash, false)
508
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
509
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
510
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
511
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).resume_recording
512
+ end
513
+
514
+ def start_participant_recording(options = {})
515
+ valid_param?(:options, options, Hash, false)
516
+ if not options[:member_id]
517
+ raise_invalid_request("Member Id is mandatory")
518
+ end
519
+ options[:file_format] = 'mp3' unless options.key?(:file_format)
520
+ options[:status_callback_method] = 'POST' unless options.key?(:status_callback_method)
521
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
522
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
523
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
524
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
525
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).start_participant_recording(options[:file_format], options[:status_callback_url], options[:status_callback_method])
526
+ end
527
+
528
+ def stop_participant_recording(options = {})
529
+ valid_param?(:options, options, Hash, false)
530
+ if not options[:member_id]
531
+ raise_invalid_request("Member Id is mandatory")
532
+ end
533
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
534
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
535
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
536
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
537
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).stop_participant_recording
538
+ end
539
+
540
+ def pause_participant_recording(options = {})
541
+ valid_param?(:options, options, Hash, false)
542
+ if not options[:member_id]
543
+ raise_invalid_request("Member Id is mandatory")
544
+ end
545
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
546
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
547
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
548
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
549
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).pause_participant_recording
550
+ end
551
+
552
+ def resume_participant_recording(options = {})
553
+ valid_param?(:options, options, Hash, false)
554
+ if not options[:member_id]
555
+ raise_invalid_request("Member Id is mandatory")
556
+ end
557
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
558
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
559
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
560
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
561
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).resume_participant_recording
562
+ end
563
+
564
+ def list_participants(options = {})
565
+ valid_param?(:options, options, Hash, false)
566
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
567
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
568
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
569
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).list_participants(options[:call_uuid])
570
+ end
571
+
572
+ def update_participant(options = {})
573
+ valid_param?(:options, options, Hash, false)
574
+ if not options[:member_id]
575
+ raise_invalid_request("Member Id is mandatory")
576
+ end
577
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
578
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
579
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
580
+ mpc_id = self.make_mpc_id(options[:uuid], options[:friendly_name])
581
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).update_participant(options[:coach_mode], options[:mute], options[:hold])
582
+ end
583
+
584
+ def kick_participant(options = {})
585
+ valid_param?(:options, options, Hash, false)
586
+ if not options[:member_id]
587
+ raise_invalid_request("Member Id is mandatory")
588
+ end
589
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
590
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
591
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
592
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
593
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).kick_participant
594
+ end
595
+
596
+ def get_participant(options = {})
597
+ valid_param?(:options, options, Hash, false)
598
+ if not options[:member_id]
599
+ raise_invalid_request("Member Id is mandatory")
600
+ end
601
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
602
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
603
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
604
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
605
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).get_participant
606
+ end
607
+
608
+ def start_play_audio(options = {})
609
+ valid_param?(:options, options, Hash, false)
610
+ if not options[:member_id]
611
+ raise_invalid_request("Member Id is mandatory")
612
+ end
613
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
614
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
615
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
616
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
617
+ MultiPartyCallMember.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).start_play_audio(options[:url])
618
+ end
619
+
620
+ def stop_play_audio(options = {})
621
+ valid_param?(:options, options, Hash, false)
622
+ if not options[:member_id]
623
+ raise_invalid_request("Member Id is mandatory")
624
+ end
625
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
626
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
627
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
628
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
629
+ MultiPartyCallMember.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).stop_play_audio
630
+ end
631
+ end
632
+ end
633
+ end
@@ -17,6 +17,7 @@ require_relative 'resources/call_feedback'
17
17
  require_relative 'resources/media'
18
18
  require_relative 'resources/lookup'
19
19
  require_relative 'resources/regulatory_compliance'
20
+ require_relative 'resources/multipartycalls'
20
21
 
21
22
  module Plivo
22
23
  module Resources
@@ -8,7 +8,7 @@ module Plivo
8
8
  # Resources
9
9
  attr_reader :messages, :account, :subaccounts, :recordings
10
10
  attr_reader :pricings, :numbers, :calls, :conferences
11
- attr_reader :phone_numbers, :applications, :endpoints
11
+ attr_reader :phone_numbers, :applications, :endpoints, :multipartycalls
12
12
  attr_reader :addresses, :identities
13
13
  attr_reader :call_feedback
14
14
  attr_reader :powerpacks
@@ -51,6 +51,7 @@ module Plivo
51
51
  @addresses = Resources::AddressInterface.new(self)
52
52
  @identities = Resources::IdentityInterface.new(self)
53
53
  @call_feedback = Resources::CallFeedbackInterface.new(self)
54
+ @multipartycalls = Resources::MultiPartyCallInterface.new( self)
54
55
  @lookup = Resources::LookupInterface.new(self)
55
56
  @end_users = Resources::EndUsersInterface.new(self)
56
57
  @compliance_document_types = Resources::ComplianceDocumentTypesInterface.new(self)