plivo 4.17.1 → 4.21.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,554 @@
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
+ if (from and to) and call_uuid
65
+ raise_invalid_request('cannot specify call_uuid when (from, to) is provided')
66
+ end
67
+ if not from and not to and not call_uuid
68
+ raise_invalid_request('specify either call_uuid or (from, to)')
69
+ end
70
+ if call_uuid.nil? and (not from or not to)
71
+ raise_invalid_request('specify (from, to) when not adding an existing call_uuid to multi party participant')
72
+ end
73
+
74
+ valid_param?(:role, role.downcase, String, true, %w[agent supervisor customer])
75
+ valid_param?(:from, from, String, false ) unless from.nil?
76
+ valid_param?(:to, to, String, false ) unless to.nil?
77
+ valid_multiple_destination_nos?(:to, to, role: role, delimiter: '<', agent_limit: 20) unless to.nil?
78
+ valid_param?(:call_uuid, call_uuid, String, false ) unless call_uuid.nil?
79
+ valid_param?(:caller_name, caller_name, String, false) unless caller_name.nil?
80
+ valid_range?(:caller_name, caller_name.length, false, 0, 50) unless caller_name.nil?
81
+ valid_url?(:call_status_callback_url, call_status_callback_url, false) unless call_status_callback_url.nil?
82
+ valid_param?(:call_status_callback_method, call_status_callback_method.upcase, String, false, %w[GET POST])
83
+ valid_param?(:sip_headers, sip_headers, String, false) unless sip_headers.nil?
84
+ valid_param?(:confirm_key, confirm_key, String, false , %w[0 1 2 3 4 5 6 7 8 9 # *]) unless confirm_key.nil?
85
+ valid_url?(:confirm_key_sound_url, confirm_key_sound_url, false) unless confirm_key_sound_url.nil?
86
+ valid_param?(:confirm_key_sound_method, confirm_key_sound_method.upcase, String, false, %w[GET POST])
87
+ is_one_among_string_url?(:dial_music, dial_music, false, %w[real none])
88
+ valid_param?(:ring_timeout, ring_timeout, [String,Integer], false)
89
+ valid_multiple_destination_integers?(:ring_timeout, ring_timeout)
90
+ valid_param?(:delay_dial, delay_dial, [String,Integer], false)
91
+ valid_multiple_destination_integers?(:delay_dial, delay_dial)
92
+ valid_range?(:max_duration, max_duration, false, 300, 28800)
93
+ valid_range?(:max_participants, max_participants, false, 2, 10)
94
+ valid_url?(:wait_music_url, wait_music_url, false ) unless wait_music_url.nil?
95
+ valid_param?(:wait_music_method, wait_music_method.upcase, String, false , %w[GET POST])
96
+ valid_url?(:agent_hold_music_url, agent_hold_music_url, false) unless agent_hold_music_url.nil?
97
+ valid_param?(:agent_hold_music_method, agent_hold_music_method.upcase, String, false , %w[GET POST])
98
+ valid_url?(:customer_hold_music_url, customer_hold_music_url, false) unless customer_hold_music_url.nil?
99
+ valid_param?(:customer_hold_music_method, customer_hold_music_method.upcase, String, false, %w[GET POST])
100
+ valid_url?(:recording_callback_url, recording_callback_url, false) unless recording_callback_url.nil?
101
+ valid_param?(:recording_callback_method, recording_callback_method.upcase, String, false, %w[GET POST])
102
+ valid_url?(:status_callback_url, status_callback_url, false) unless status_callback_url.nil?
103
+ valid_param?(:status_callback_method, status_callback_method.upcase, String, false, %w[GET POST])
104
+ valid_url?(:on_exit_action_url, on_exit_action_url, false ) unless on_exit_action_url.nil?
105
+ valid_param?(:on_exit_action_method, on_exit_action_method.upcase, String, false, %w[GET POST])
106
+ valid_param?(:record, record, [TrueClass, FalseClass], false )
107
+ valid_param?(:record_file_format, record_file_format.downcase, String, false, %w[mp3 wav])
108
+ 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, ',')
109
+ valid_param?(:stay_alone, stay_alone, [TrueClass, FalseClass], false)
110
+ valid_param?(:coach_mode, coach_mode, [TrueClass, FalseClass], false)
111
+ valid_param?(:mute, mute, [TrueClass, FalseClass],false)
112
+ valid_param?(:hold, hold, [TrueClass, FalseClass], false)
113
+ valid_param?(:start_mpc_on_enter, start_mpc_on_enter, [TrueClass, FalseClass], false)
114
+ valid_param?(:end_mpc_on_exit, end_mpc_on_exit, [TrueClass, FalseClass], false)
115
+ valid_param?(:relay_dtmf_inputs, relay_dtmf_inputs, [TrueClass, FalseClass], false)
116
+ is_one_among_string_url?(:enter_sound, enter_sound, false, %w[beep:1 beep:2 none])
117
+ valid_param?(:enter_sound_method, enter_sound_method.upcase, String, false, %w[GET POST])
118
+ is_one_among_string_url?(:exit_sound, exit_sound, false , %w[beep:1 beep:2 none])
119
+ valid_param?(:exit_sound_method, exit_sound_method.upcase, String, false, %w[GET POST])
120
+ if (to!=nil) && (ring_timeout.is_a?(String)) && (to.split('<').size < ring_timeout.split('<').size)
121
+ raise_invalid_request("RingTimeout:number of ring_timout(s) should be same as number of destination(s)")
122
+ end
123
+
124
+ if (to!=nil) && (delay_dial.is_a?(String)) && (to.split('<').size < delay_dial.split('<').size)
125
+ raise_invalid_request("Delaydial : number of delay_dial(s) should be same as number of destination(s)")
126
+ end
127
+
128
+ params = {}
129
+ params[:role] = role unless role.nil?
130
+ params[:from] = from unless from.nil?
131
+ params[:to] = to unless to.nil?
132
+ params[:call_uuid] = call_uuid unless call_uuid.nil?
133
+ params[:caller_name] = caller_name || from
134
+ params[:call_status_callback_url] = call_status_callback_url unless call_status_callback_url.nil?
135
+ params[:call_status_callback_method] = call_status_callback_method.upcase unless call_status_callback_method.nil?
136
+ params[:sip_headers] = sip_headers unless sip_headers.nil?
137
+ params[:confirm_key] = confirm_key unless confirm_key.nil?
138
+ params[:confirm_key_sound_url] = confirm_key_sound_url unless confirm_key_sound_url.nil?
139
+ params[:confirm_key_sound_method] = confirm_key_sound_method.upcase unless confirm_key_sound_method.nil?
140
+ params[:dial_music] = dial_music unless dial_music.nil?
141
+ params[:ring_timeout] = ring_timeout unless ring_timeout.nil?
142
+ params[:delay_dial] = delay_dial unless delay_dial.nil?
143
+ params[:max_duration] = max_duration unless max_duration.nil?
144
+ params[:max_participants] = max_participants unless max_participants.nil?
145
+ params[:wait_music_url] = wait_music_url unless wait_music_url.nil?
146
+ params[:wait_music_method] = wait_music_method.upcase unless wait_music_method.nil?
147
+ params[:agent_hold_music_url] = agent_hold_music_url unless agent_hold_music_url.nil?
148
+ params[:agent_hold_music_method] = agent_hold_music_method.upcase unless agent_hold_music_method.nil?
149
+ params[:customer_hold_music_url] = customer_hold_music_url unless customer_hold_music_url.nil?
150
+ params[:customer_hold_music_method] = customer_hold_music_method.upcase unless customer_hold_music_method.nil?
151
+ params[:recording_callback_url] = recording_callback_url unless recording_callback_url.nil?
152
+ params[:recording_callback_method] = recording_callback_method.upcase unless recording_callback_method.nil?
153
+ params[:status_callback_url] = status_callback_url unless status_callback_url.nil?
154
+ params[:status_callback_method] = status_callback_method.upcase unless status_callback_method.nil?
155
+ params[:on_exit_action_url] = on_exit_action_url unless on_exit_action_url.nil?
156
+ params[:on_exit_action_method] = on_exit_action_method.upcase unless on_exit_action_method.nil?
157
+ params[:record] = record unless record.nil?
158
+ params[:record_file_format] = record_file_format.downcase unless record_file_format.nil?
159
+ params[:status_callback_events] = status_callback_events.downcase unless status_callback_events.nil?
160
+ params[:stay_alone] = stay_alone unless stay_alone.nil?
161
+ params[:coach_mode] = coach_mode unless coach_mode.nil?
162
+ params[:mute] = mute unless mute.nil?
163
+ params[:hold] = hold unless hold.nil?
164
+ params[:start_mpc_on_enter] = start_mpc_on_enter unless start_mpc_on_enter.nil?
165
+ params[:end_mpc_on_exit] = end_mpc_on_exit unless end_mpc_on_exit.nil?
166
+ params[:relay_dtmf_inputs] = relay_dtmf_inputs unless relay_dtmf_inputs.nil?
167
+ params[:enter_sound] = enter_sound unless enter_sound.nil?
168
+ params[:enter_sound_method] = enter_sound_method.upcase unless exit_sound_method.nil?
169
+ params[:exit_sound] = exit_sound unless exit_sound.nil?
170
+ params[:exit_sound_method] = exit_sound_method.upcase unless exit_sound_method.nil?
171
+ perform_action_apiresponse('Participant', 'POST', params, true )
172
+ end
173
+
174
+ def start
175
+ perform_action_apiresponse(nil, 'POST', Hash['status' => 'active'], true)
176
+ end
177
+
178
+ def stop
179
+ perform_action_apiresponse(nil, 'DELETE', nil, true)
180
+ end
181
+
182
+ def start_recording(file_format = 'mp3', status_callback_url = nil, status_callback_method='POST')
183
+ valid_param?(:file_format, file_format, String, false , %w[mp3 wav])
184
+ valid_url?(:status_callback_url, status_callback_url, false) unless status_callback_url.nil?
185
+ valid_param?(:status_callback_method, status_callback_method.upcase,String, false, %w[GET POST])
186
+
187
+ params = {}
188
+ params[:file_format] = file_format.downcase unless file_format.nil?
189
+ params[:status_callback_url] = status_callback_url unless status_callback_url.nil?
190
+ params[:status_callback_method] = status_callback_method.upcase unless status_callback_method.nil?
191
+
192
+ perform_action_apiresponse('Record', 'POST', params, true)
193
+ end
194
+
195
+ def stop_recording
196
+ perform_action_apiresponse('Record', 'DELETE')
197
+ end
198
+
199
+ def pause_recording
200
+ perform_action_apiresponse('Record/Pause', 'POST')
201
+ end
202
+
203
+ def resume_recording
204
+ perform_action_apiresponse('Record/Resume', 'POST')
205
+ end
206
+
207
+
208
+ def start_participant_recording(member_id, file_format='mp3', status_callback_url=nil, status_callback_method='POST')
209
+ valid_param?(:member_id, member_id, [String, Integer], true)
210
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).start_participant_recording(file_format, status_callback_url, status_callback_method)
211
+ end
212
+
213
+ def stop_participant_recording(member_id)
214
+ valid_param?(:member_id, member_id, [String, Integer], true)
215
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).stop_participant_recording
216
+ end
217
+
218
+ def pause_participant_recording(member_id)
219
+ valid_param?(:member_id, member_id, [String, Integer], true)
220
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).pause_participant_recording
221
+ end
222
+
223
+ def resume_participant_recording(member_id)
224
+ valid_param?(:member_id, member_id, [String, Integer], true)
225
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], member_id: member_id).resume_participant_recording
226
+ end
227
+
228
+ def list_participants(call_uuid = nil )
229
+ valid_param?(:call_uuid, call_uuid, String, false) unless call_uuid.nil?
230
+ params = {}
231
+ params[:call_uuid] = call_uuid unless call_uuid.nil?
232
+ perform_action('Participant', 'GET', params, true)
233
+ end
234
+
235
+ def update_participant(member_id, coach_mode = nil, mute = nil , hold = nil)
236
+ valid_param?(:member_id, member_id, [String, Integer], true)
237
+ MultiPartyCallParticipant.new(@_client, resource_id: @id, member_id: member_id).update_participant(coach_mode, mute, hold)
238
+ end
239
+
240
+ def kick_participant(member_id)
241
+ valid_param?(:member_id, member_id, [String, Integer], true)
242
+ MultiPartyCallParticipant.new(@_client, resource_id: @id, member_id: member_id).kick_participant
243
+ end
244
+
245
+ def get_participant(member_id)
246
+ valid_param?(:member_id, member_id, [String, Integer], true)
247
+ MultiPartyCallParticipant.new(@_client,resource_id: @id, member_id: member_id).get_participant
248
+ end
249
+ end
250
+
251
+ class MultiPartyCallParticipant < Base::SecondaryResource
252
+ def initialize(client, options = nil)
253
+ @_name = 'MultiPartyCall'
254
+ @_identifier_string = 'mpc_uuid'
255
+ @_secondary_name = 'Participant'
256
+ @_secondary_identifier_string = 'member_id'
257
+ super
258
+ @_is_voice_request = true
259
+ if options.key? :multi_party_prefix
260
+ @id = options[:multi_party_prefix] + '_' + @id
261
+ elsif @id.split('_').size > 1
262
+ nil
263
+ else
264
+ @id = 'uuid_' + @id
265
+ end
266
+ configure_secondary_resource_uri
267
+ end
268
+
269
+ def start_participant_recording(file_format = 'mp3', status_callback_url = nil, status_callback_method='POST')
270
+ valid_param?(:file_format, file_format, String, false , %w[mp3 wav])
271
+ valid_url?(:status_callback_url, status_callback_url, false) unless status_callback_url.nil?
272
+ valid_param?(:status_callback_method, status_callback_method.upcase,String, false, %w[GET POST])
273
+
274
+ params = {}
275
+ params[:file_format] = file_format.downcase unless file_format.nil?
276
+ params[:status_callback_url] = status_callback_url unless status_callback_url.nil?
277
+ params[:status_callback_method] = status_callback_method.upcase unless status_callback_method.nil?
278
+
279
+ perform_action_apiresponse('Record', 'POST', params, true)
280
+ end
281
+
282
+ def stop_participant_recording
283
+ perform_action_apiresponse('Record', 'DELETE')
284
+ end
285
+
286
+ def pause_participant_recording
287
+ perform_action_apiresponse('Record/Pause', 'POST')
288
+ end
289
+
290
+ def resume_participant_recording
291
+ perform_action_apiresponse('Record/Resume', 'POST')
292
+ end
293
+
294
+ def update_participant(coach_mode = nil, mute= nil, hold = nil)
295
+ valid_param?(:coach_mode, coach_mode, [TrueClass, FalseClass], false) unless coach_mode.nil?
296
+ valid_param?(:mute, mute, [TrueClass, FalseClass], false) unless mute.nil?
297
+ valid_param?(:hold, hold, [TrueClass, FalseClass], false) unless hold.nil?
298
+ params = {}
299
+ params[:coach_mode] = coach_mode unless coach_mode.nil?
300
+ params[:mute] = mute unless mute.nil?
301
+ params[:hold] = hold unless hold.nil?
302
+ perform_action_apiresponse(nil, 'POST', params, true )
303
+ end
304
+
305
+ def kick_participant
306
+ perform_action_apiresponse(nil, 'DELETE', nil, true)
307
+ end
308
+
309
+ def get_participant
310
+ perform_action_apiresponse(nil,'GET',nil,false)
311
+ end
312
+ end
313
+
314
+ class MultiPartyCallInterface < Base::ResourceInterface
315
+ def initialize(client, resource_list_json = nil)
316
+ @_name = 'MultiPartyCall'
317
+ @_resource_type = MultiPartyCall
318
+ @_identifier_string = 'mpc_uuid'
319
+ super
320
+ @_is_voice_request = true
321
+ end
322
+
323
+ def make_mpc_id(uuid=nil, friendly_name=nil)
324
+ if not uuid and not friendly_name
325
+ raise_invalid_request('specify either multi party call friendly name or uuid')
326
+ end
327
+ if uuid and friendly_name
328
+ raise_invalid_request('cannot specify both multi party call friendly name or uuid')
329
+ end
330
+ if uuid
331
+ identifier = ['uuid', uuid]
332
+ else
333
+ identifier = ['name', friendly_name]
334
+ end
335
+ return identifier
336
+ end
337
+
338
+ def list(options={})
339
+ valid_param?(:options, options, Hash, false)
340
+ valid_subaccount?(options[:sub_account], true) unless options[:sub_account].nil?
341
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
342
+ valid_param?(:status, options[:status].downcase, String, false, %w[initialized active ended]) unless options[:status].nil?
343
+ valid_param?(:termination_cause_code, options[:termination_cause_code], Integer, false) unless options[:termination_cause_code].nil?
344
+ valid_date_format?(:end_time__gt, options[:end_time__gt], false ) unless options[:end_time__gt].nil?
345
+ valid_date_format?(:end_time__gte, options[:end_time__gte], false ) unless options[:end_time__gte].nil?
346
+ valid_date_format?(:end_time__lt, options[:end_time__lt], String) unless options[:end_time__lt].nil?
347
+ valid_date_format?(:end_time__lte, options[:end_time__lte], false) unless options[:end_time__lte].nil?
348
+ valid_date_format?(:creation_time__gt, options[:creation_time__gt], false) unless options[:creation_time__gt].nil?
349
+ valid_date_format?(:creation_time__gte, options[:creation_time__gte], false) unless options[:creation_time__gte].nil?
350
+ valid_date_format?(:creation_time__lt, options[:creation_time__lt], false) unless options[:creation_time__lt].nil?
351
+ valid_date_format?(:creation_time__lte, options[:creation_time__lte], false) unless options[:creation_time__lte].nil?
352
+ valid_range?(:limit, options[:limit], false, 1, 20)
353
+ valid_range?(:offset, options[:offset], false, 0)
354
+ perform_action(nil ,'GET', options ,true )
355
+ end
356
+
357
+ def get(options = {})
358
+ valid_param?(:options, options, Hash, false)
359
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
360
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
361
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
362
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).get
363
+ end
364
+
365
+ def add_participant(options = {})
366
+ valid_param?(:options, options, Hash, false)
367
+ if not options[:role ]
368
+ raise_invalid_request("Role is mandatory")
369
+ end
370
+ options[:call_status_callback_method] = 'POST' unless options.key?(:call_status_callback_method)
371
+ options[:confirm_key_sound_method] = 'GET' unless options.key?(:confirm_key_sound_method)
372
+ options[:dial_music] = 'Real' unless options.key?(:dial_music)
373
+ options[:ring_timeout] = 45 unless options.key?(:ring_timeout)
374
+ options[:delay_dial] = 0 unless options.key?(:delay_dial)
375
+ options[:max_duration] = 14400 unless options.key?(:max_duration)
376
+ options[:max_participants] = 10 unless options.key?(:max_participants)
377
+ options[:wait_music_method] = 'GET' unless options.key?(:wait_music_method)
378
+ options[:agent_hold_music_method] = 'GET' unless options.key?(:agent_hold_music_method)
379
+ options[:customer_hold_music_method] = 'GET' unless options.key?(:customer_hold_music_method)
380
+ options[:recording_callback_method] ='GET' unless options.key?(:recording_callback_method)
381
+ options[:status_callback_method] = 'GET' unless options.key?(:status_callback_method)
382
+ options[:on_exit_action_method] = 'POST' unless options.key?(:on_exit_action_method)
383
+ options[:record] = false unless options.key?(:record)
384
+ options[:record_file_format] = 'mp3' unless options.key?(:record_file_format)
385
+ options[:status_callback_events] = 'mpc-state-changes,participant-state-changes' unless options.key?(:status_callback_events)
386
+ options[:stay_alone] = false unless options.key?(:stay_alone)
387
+ options[:coach_mode] = true unless options.key?(:coach_mode)
388
+ options[:mute] = false unless options.key?(:mute)
389
+ options[:hold] = false unless options.key?(:hold)
390
+ options[:start_mpc_on_enter] = true unless options.key?(:start_mpc_on_enter)
391
+ options[:end_mpc_on_exit] = false unless options.key?(:end_mpc_on_exit)
392
+ options[:relay_dtmf_inputs] = false unless options.key?(:relay_dtmf_inputs)
393
+ options[:enter_sound] = 'beep:1' unless options.key?(:enter_sound)
394
+ options[:enter_sound_method] = 'GET' unless options.key?(:enter_sound_method)
395
+ options[:exit_sound] = 'beep:2' unless options.key?(:exit_sound)
396
+ options[:exit_sound_method] = 'GET' unless options.key?(:exit_sound_method)
397
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
398
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
399
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
400
+
401
+ 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],
402
+ 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],
403
+ options[:wait_music_method],options[:agent_hold_music_url],options[:agent_hold_music_method],options[:customer_hold_music_url],options[:customer_hold_music_method],
404
+ 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],
405
+ 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],
406
+ options[:relay_dtmf_inputs],options[:enter_sound],options[:enter_sound_method],options[:exit_sound],options[:exit_sound_method])
407
+ end
408
+
409
+ def start(options = {})
410
+ valid_param?(:options, options, Hash, false)
411
+ valid_param?(:uuid, options[:uuid], String, false)
412
+ valid_param?(:friendly_name, options[:friendly_name], String, false)
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]).start
415
+ end
416
+
417
+ def stop(options = {})
418
+ valid_param?(:options, options, Hash, false)
419
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
420
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
421
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
422
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).stop
423
+ end
424
+
425
+ def start_recording(options = {})
426
+ valid_param?(:options, options, Hash, false)
427
+ options[:file_format] = 'mp3' unless options.key?(:file_format)
428
+ options[:status_callback_method] = 'POST' unless options.key?(:status_callback_method)
429
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
430
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
431
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
432
+ 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])
433
+ end
434
+
435
+ def stop_recording(options = {})
436
+ valid_param?(:options, options, Hash, false)
437
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
438
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
439
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
440
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).stop_recording
441
+ end
442
+
443
+ def pause_recording(options = {})
444
+ valid_param?(:options, options, Hash, false)
445
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
446
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
447
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
448
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).pause_recording
449
+ end
450
+
451
+ def resume_recording(options = {})
452
+ valid_param?(:options, options, Hash, false)
453
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
454
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
455
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
456
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).resume_recording
457
+ end
458
+
459
+ def start_participant_recording(options = {})
460
+ valid_param?(:options, options, Hash, false)
461
+ if not options[:member_id]
462
+ raise_invalid_request("Member Id is mandatory")
463
+ end
464
+ options[:file_format] = 'mp3' unless options.key?(:file_format)
465
+ options[:status_callback_method] = 'POST' unless options.key?(:status_callback_method)
466
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
467
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
468
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
469
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
470
+ 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])
471
+ end
472
+
473
+ def stop_participant_recording(options = {})
474
+ valid_param?(:options, options, Hash, false)
475
+ if not options[:member_id]
476
+ raise_invalid_request("Member Id is mandatory")
477
+ end
478
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
479
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
480
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
481
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
482
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).stop_participant_recording
483
+ end
484
+
485
+ def pause_participant_recording(options = {})
486
+ valid_param?(:options, options, Hash, false)
487
+ if not options[:member_id]
488
+ raise_invalid_request("Member Id is mandatory")
489
+ end
490
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
491
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
492
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
493
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
494
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).pause_participant_recording
495
+ end
496
+
497
+ def resume_participant_recording(options = {})
498
+ valid_param?(:options, options, Hash, false)
499
+ if not options[:member_id]
500
+ raise_invalid_request("Member Id is mandatory")
501
+ end
502
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
503
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
504
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
505
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
506
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).resume_participant_recording
507
+ end
508
+
509
+ def list_participants(options = {})
510
+ valid_param?(:options, options, Hash, false)
511
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
512
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
513
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
514
+ MultiPartyCall.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0]).list_participants(options[:call_uuid])
515
+ end
516
+
517
+ def update_participant(options = {})
518
+ valid_param?(:options, options, Hash, false)
519
+ if not options[:member_id]
520
+ raise_invalid_request("Member Id is mandatory")
521
+ end
522
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
523
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
524
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
525
+ mpc_id = self.make_mpc_id(options[:uuid], options[:friendly_name])
526
+ 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])
527
+ end
528
+
529
+ def kick_participant(options = {})
530
+ valid_param?(:options, options, Hash, false)
531
+ if not options[:member_id]
532
+ raise_invalid_request("Member Id is mandatory")
533
+ end
534
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
535
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
536
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
537
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
538
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).kick_participant
539
+ end
540
+
541
+ def get_participant(options = {})
542
+ valid_param?(:options, options, Hash, false)
543
+ if not options[:member_id]
544
+ raise_invalid_request("Member Id is mandatory")
545
+ end
546
+ valid_param?(:member_id, options[:member_id], [String, Integer], true)
547
+ valid_param?(:uuid, options[:uuid], String, false) unless options[:uuid].nil?
548
+ valid_param?(:friendly_name, options[:friendly_name], String, false) unless options[:friendly_name].nil?
549
+ mpc_id = make_mpc_id(options[:uuid], options[:friendly_name])
550
+ MultiPartyCallParticipant.new(@_client, resource_id: mpc_id[1], multi_party_prefix: mpc_id[0], member_id: options[:member_id]).get_participant
551
+ end
552
+ end
553
+ end
554
+ 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)