plivo 4.16.0 → 4.58.0

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