plivo 0.3.19 → 4.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +11 -0
  5. data/AUTHORS.md +4 -0
  6. data/CHANGELOG.md +158 -0
  7. data/Gemfile +10 -0
  8. data/Jenkinsfile +7 -0
  9. data/LICENSE.txt +19 -0
  10. data/README.md +155 -24
  11. data/Rakefile +9 -0
  12. data/ci/config.yml +7 -0
  13. data/examples/conference_bridge.rb +108 -0
  14. data/examples/jwt.rb +32 -0
  15. data/examples/lookup.rb +24 -0
  16. data/examples/multi_party_call.rb +295 -0
  17. data/examples/phlos.rb +55 -0
  18. data/examples/regulatory_compliance.rb +167 -0
  19. data/lib/plivo/base/resource.rb +148 -0
  20. data/lib/plivo/base/resource_interface.rb +108 -0
  21. data/lib/plivo/base/response.rb +38 -0
  22. data/lib/plivo/base.rb +17 -0
  23. data/lib/plivo/base_client.rb +393 -0
  24. data/lib/plivo/exceptions.rb +50 -0
  25. data/lib/plivo/jwt.rb +120 -0
  26. data/lib/plivo/phlo_client.rb +29 -0
  27. data/lib/plivo/resources/accounts.rb +181 -0
  28. data/lib/plivo/resources/addresses.rb +302 -0
  29. data/lib/plivo/resources/applications.rb +258 -0
  30. data/lib/plivo/resources/call_feedback.rb +55 -0
  31. data/lib/plivo/resources/calls.rb +559 -0
  32. data/lib/plivo/resources/conferences.rb +367 -0
  33. data/lib/plivo/resources/endpoints.rb +132 -0
  34. data/lib/plivo/resources/identities.rb +319 -0
  35. data/lib/plivo/resources/lookup.rb +88 -0
  36. data/lib/plivo/resources/media.rb +97 -0
  37. data/lib/plivo/resources/messages.rb +215 -0
  38. data/lib/plivo/resources/multipartycalls.rb +554 -0
  39. data/lib/plivo/resources/nodes.rb +83 -0
  40. data/lib/plivo/resources/numbers.rb +319 -0
  41. data/lib/plivo/resources/phlo_member.rb +64 -0
  42. data/lib/plivo/resources/phlos.rb +55 -0
  43. data/lib/plivo/resources/powerpacks.rb +717 -0
  44. data/lib/plivo/resources/pricings.rb +43 -0
  45. data/lib/plivo/resources/recordings.rb +116 -0
  46. data/lib/plivo/resources/regulatory_compliance.rb +610 -0
  47. data/lib/plivo/resources.rb +25 -0
  48. data/lib/plivo/rest_client.rb +63 -0
  49. data/lib/plivo/utils.rb +294 -0
  50. data/lib/plivo/version.rb +3 -0
  51. data/lib/plivo/xml/break.rb +31 -0
  52. data/lib/plivo/xml/conference.rb +20 -0
  53. data/lib/plivo/xml/cont.rb +13 -0
  54. data/lib/plivo/xml/dial.rb +16 -0
  55. data/lib/plivo/xml/dtmf.rb +13 -0
  56. data/lib/plivo/xml/element.rb +106 -0
  57. data/lib/plivo/xml/emphasis.rb +17 -0
  58. data/lib/plivo/xml/get_digits.rb +15 -0
  59. data/lib/plivo/xml/get_input.rb +16 -0
  60. data/lib/plivo/xml/hangup.rb +12 -0
  61. data/lib/plivo/xml/lang.rb +29 -0
  62. data/lib/plivo/xml/message.rb +13 -0
  63. data/lib/plivo/xml/multipartycall.rb +188 -0
  64. data/lib/plivo/xml/number.rb +13 -0
  65. data/lib/plivo/xml/p.rb +12 -0
  66. data/lib/plivo/xml/phoneme.rb +20 -0
  67. data/lib/plivo/xml/play.rb +13 -0
  68. data/lib/plivo/xml/plivo_xml.rb +19 -0
  69. data/lib/plivo/xml/pre_answer.rb +12 -0
  70. data/lib/plivo/xml/prosody.rb +28 -0
  71. data/lib/plivo/xml/record.rb +17 -0
  72. data/lib/plivo/xml/redirect.rb +13 -0
  73. data/lib/plivo/xml/response.rb +21 -0
  74. data/lib/plivo/xml/s.rb +12 -0
  75. data/lib/plivo/xml/say_as.rb +24 -0
  76. data/lib/plivo/xml/speak.rb +28 -0
  77. data/lib/plivo/xml/sub.rb +16 -0
  78. data/lib/plivo/xml/user.rb +13 -0
  79. data/lib/plivo/xml/w.rb +17 -0
  80. data/lib/plivo/xml/wait.rb +12 -0
  81. data/lib/plivo/xml.rb +39 -0
  82. data/lib/plivo.rb +12 -815
  83. data/plivo.gemspec +44 -0
  84. metadata +181 -41
  85. data/ext/mkrf_conf.rb +0 -9
@@ -0,0 +1,610 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+
5
+ class EndUser < Base::Resource
6
+ def initialize(client, options = nil)
7
+ @_name = 'EndUser'
8
+ @_identifier_string = 'end_user'
9
+ super
10
+ end
11
+
12
+ def update(options = nil)
13
+ return perform_update({}) if options.nil?
14
+
15
+ valid_param?(:options, options, Hash, true)
16
+
17
+ params = {}
18
+ params_expected = %i[ name last_name ]
19
+ params_expected.each do |param|
20
+ if options.key?(param) &&
21
+ valid_param?(param, options[param], [String, Symbol], false)
22
+ params[param] = options[param]
23
+ end
24
+ end
25
+
26
+ if options.key?(:end_user_type) &&
27
+ valid_param?(:end_user_type, options[:end_user_type].capitalize,[String, Symbol], false, %w[Business Individual])
28
+ params[:end_user_type] = options[:end_user_type].capitalize
29
+ end
30
+
31
+ perform_update(params)
32
+ end
33
+
34
+ def delete
35
+ perform_delete
36
+ end
37
+
38
+ def to_s
39
+ {
40
+ api_id: @api_id,
41
+ end_user_id: @end_user_id,
42
+ end_user_type: @end_user_type,
43
+ name: @name,
44
+ last_name: @last_name,
45
+ created_at: @created_at
46
+ }.delete_if { |key, value| value.nil? }.to_s
47
+ end
48
+ end
49
+
50
+ class EndUsersInterface < Base::ResourceInterface
51
+ def initialize(client, resource_list_json = nil)
52
+ @_name = 'EndUser'
53
+ @_resource_type = EndUser
54
+ @_identifier_string = 'end_user'
55
+ super
56
+ end
57
+
58
+ ##
59
+ # Get an EndUser
60
+ # @param [String] end_user_id
61
+ # return [EndUser]
62
+ def get(end_user_id)
63
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
64
+ perform_get(end_user_id)
65
+ end
66
+
67
+ ##
68
+ # List all EndUser
69
+ # @param [Hash] options
70
+ # @option options [Int] :offset
71
+ # @option options [Int] :limit
72
+ # @return [Hash]
73
+ def list(options = nil)
74
+ return perform_list if options.nil?
75
+ valid_param?(:options, options, Hash, true)
76
+
77
+ params = {}
78
+ params_expected = %i[ name last_name ]
79
+ params_expected.each do |param|
80
+ if options.key?(param) &&
81
+ valid_param?(param, options[param], [String, Symbol], false)
82
+ params[param] = options[param]
83
+ end
84
+ end
85
+
86
+ if options.key?(:end_user_type) &&
87
+ valid_param?(:end_user_type, options[:end_user_type].capitalize,[String, Symbol], false, %w[Business Individual])
88
+ params[:end_user_type] = options[:end_user_type].capitalize
89
+ end
90
+
91
+ %i[offset limit].each do |param|
92
+ if options.key?(param) && valid_param?(param, options[param],
93
+ [Integer], true)
94
+ params[param] = options[param]
95
+ end
96
+ end
97
+
98
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
99
+
100
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
101
+ raise_invalid_request('The maximum number of results that can be '\
102
+ "fetched is 20. limit can't be more than 20 or less than 1")
103
+ end
104
+
105
+ perform_list(params)
106
+ end
107
+
108
+ ##
109
+ # Create an EndUser
110
+ # @param [String] name
111
+ # @param [String] last_name
112
+ # @param [String] end_user_type
113
+ # return [EndUser] EndUser
114
+ def create(name, last_name = nil , end_user_type)
115
+ valid_param?(:name, name, [String, Symbol], true)
116
+ valid_param?(:last_name, last_name, [String, Symbol], false)
117
+ valid_param?(:end_user_type, end_user_type.capitalize, [String, Symbol], true, %w[Business Individual])
118
+
119
+ params = {
120
+ name: name,
121
+ last_name: last_name,
122
+ end_user_type: end_user_type.capitalize
123
+ }
124
+
125
+ return perform_create(params)
126
+ end
127
+
128
+ ##
129
+ # Update an EndUser
130
+ # @param [String] end_user_id
131
+ # @param [Hash] options
132
+ # return [EndUser]
133
+ def update(end_user_id, options = nil)
134
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
135
+ EndUser.new(@_client,
136
+ resource_id: end_user_id).update(options)
137
+ end
138
+
139
+ ##
140
+ # Delete an EndUser.
141
+ # @param [String] end_user_id
142
+ def delete(end_user_id)
143
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
144
+ EndUser.new(@_client,
145
+ resource_id: end_user_id).delete
146
+ end
147
+ end
148
+
149
+ class ComplianceDocumentType < Base::Resource
150
+ def initialize(client, options = nil)
151
+ @_name = 'ComplianceDocumentType'
152
+ @_identifier_string = 'compliance_document_type'
153
+ super
154
+ end
155
+
156
+ def to_s
157
+ {
158
+ api_id: @api_id,
159
+ document_type_id: @document_type_id,
160
+ document_name: @document_name,
161
+ description: @description,
162
+ information: @information,
163
+ proof_required: @proof_required,
164
+ created_at: @created_at
165
+ }.delete_if { |key, value| key==:api_id && value.nil? }.to_s
166
+ end
167
+ end
168
+
169
+ class ComplianceDocumentTypesInterface < Base::ResourceInterface
170
+ def initialize(client, resource_list_json = nil)
171
+ @_name = 'ComplianceDocumentType'
172
+ @_resource_type = ComplianceDocumentType
173
+ @_identifier_string = 'compliance_document_type'
174
+ super
175
+ end
176
+
177
+ # Get a ComplianceDocumentType
178
+ # @param [String] document_type_id
179
+ # @return [ComplianceDocumentType] ComplianceDocumentType
180
+ def get(document_type_id)
181
+ valid_param?(:document_type_id, document_type_id, [String, Symbol], true)
182
+ perform_get(document_type_id)
183
+ end
184
+
185
+ ##
186
+ # List all ComplianceDocumentTypes
187
+ # @option options [Int] :offset
188
+ # @option options [Int] :limit
189
+ # @return [Hash]
190
+ def list(options = nil)
191
+ return perform_list if options.nil?
192
+ valid_param?(:options, options, Hash, false)
193
+
194
+ params = {}
195
+ %i[offset limit].each do |param|
196
+ if options.key?(param) && valid_param?(param, options[param],
197
+ [Integer], false)
198
+ params[param] = options[param]
199
+ end
200
+ end
201
+
202
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
203
+
204
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
205
+ raise_invalid_request('The maximum number of results that can be '\
206
+ "fetched is 20. limit can't be more than 20 or less than 1")
207
+ end
208
+
209
+ perform_list(params)
210
+ end
211
+ end
212
+
213
+ class ComplianceDocument < Base::Resource
214
+ def initialize(client, options = nil)
215
+ @_name = 'ComplianceDocument'
216
+ @_identifier_string = 'compliance_document'
217
+ super
218
+ end
219
+
220
+ def delete
221
+ perform_delete
222
+ end
223
+
224
+ def update(params)
225
+ perform_update(params, use_multipart_conn: true)
226
+ end
227
+
228
+ def to_s
229
+ {
230
+ api_id: @api_id,
231
+ end_user_id: @end_user_id,
232
+ document_type_id: @document_type_id,
233
+ compliance_document_id: @compliance_document_id,
234
+ document_id: @document_id,
235
+ alias: @alias,
236
+ meta_information: @meta_information,
237
+ file: @file,
238
+ file_name: @file_name,
239
+ created_at: @created_at
240
+ }.delete_if { |key, value| value.nil? }.to_s
241
+ end
242
+ end
243
+
244
+ class ComplianceDocumentsInterface < Base::ResourceInterface
245
+ def initialize(client, resource_list_json = nil)
246
+ @_name = 'ComplianceDocument'
247
+ @_resource_type = ComplianceDocument
248
+ @_identifier_string = 'compliance_document'
249
+ super
250
+ end
251
+
252
+ # Get a ComplianceDocument
253
+ # @param [String] compliance_document_id
254
+ # @return [ComplianceDocument] ComplianceDocument
255
+ def get(compliance_document_id)
256
+ valid_param?(:compliance_document_id, compliance_document_id, [String, Symbol], true)
257
+ perform_get(compliance_document_id)
258
+ end
259
+
260
+ # List all ComplianceDocuments
261
+ # @option options [Hash] :options
262
+ # @option options [Int] :offset
263
+ # @option options [Int] :limit
264
+ # @return [Hash]
265
+ def list(options = nil)
266
+ return perform_list if options.nil?
267
+ valid_param?(:options, options, Hash, false)
268
+
269
+ params = {}
270
+
271
+ params_expected = %i[ end_user_id document_type_id ]
272
+ params_expected.each do |param|
273
+ if options.key?(param) &&
274
+ valid_param?(param, options[param], [String, Symbol], false)
275
+ params[param] = options[param]
276
+ end
277
+ end
278
+
279
+ if options.key?(:alias) && valid_param?(:alias, options[:alias],[String, Symbol], false)
280
+ params[:alias] = options[:alias]
281
+ end
282
+
283
+ %i[offset limit].each do |param|
284
+ if options.key?(param) && valid_param?(param, options[param],
285
+ [Integer], true)
286
+ params[param] = options[param]
287
+ end
288
+ end
289
+
290
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
291
+
292
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
293
+ raise_invalid_request('The maximum number of results that can be '\
294
+ "fetched is 20. limit can't be more than 20 or less than 1")
295
+ end
296
+
297
+ perform_list(params)
298
+ end
299
+
300
+ # Create a ComplianceDocument
301
+ # @param [String] end_user_id
302
+ # @param [String] document_type_id
303
+ # @param [String] alias_
304
+ # @param [String] file
305
+ # @param [Hash] options
306
+ # @return [ComplianceDocument] ComplianceDocument
307
+ def create(end_user_id: nil , document_type_id: nil, alias_: nil, file: nil, **options)
308
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], true)
309
+ valid_param?(:document_type_id, document_type_id, [String, Symbol], true)
310
+ valid_param?(:alias, :alias_, [String, Symbol], true)
311
+
312
+ params = {
313
+ end_user_id: end_user_id,
314
+ document_type_id: document_type_id,
315
+ alias: alias_
316
+ }
317
+
318
+ if !options.nil?
319
+ valid_param?(:options, options, Hash, false)
320
+ options.each do |key, value|
321
+ if valid_param?(key, value, [String, Symbol], false)
322
+ params[key] = value
323
+ end
324
+ end
325
+ end
326
+
327
+ upload(file, params) if !file.nil?
328
+
329
+ perform_create(params, use_multipart_conn: true)
330
+ end
331
+
332
+ # Update a ComplianceDocument
333
+ # @param [String] compliance_document_id
334
+ # @param [Hash] options
335
+ # return [ComplianceDocument] ComplianceDocument
336
+ def update(compliance_document_id, options = nil)
337
+ valid_param?(:compliance_document_id, compliance_document_id, [String, Symbol], true)
338
+ valid_param?(:options, options, Hash, true) if !options.nil?
339
+ params = {}
340
+
341
+ options.each do |key, value|
342
+ params[key] = value
343
+ end
344
+
345
+ upload(params[:file], params) if params.key?(:file)
346
+
347
+ ComplianceDocument.new(@_client, resource_id: compliance_document_id).update(params)
348
+ end
349
+
350
+ # Delete a ComplianceDocument
351
+ # @param [String] compliance_document_id
352
+ def delete(compliance_document_id)
353
+ valid_param?(:compliance_document_id, compliance_document_id, [String, Symbol], true)
354
+ ComplianceDocument.new(@_client, resource_id: compliance_document_id).delete
355
+ end
356
+
357
+ private
358
+
359
+ def upload(filepath, params)
360
+ file_extension = filepath.split('.')[-1]
361
+
362
+ content_type = case file_extension
363
+ when 'jpeg' then 'image/jpeg'
364
+ when 'jpg' then 'image/jpeg'
365
+ when 'png' then 'image/png'
366
+ when 'pdf' then 'application/pdf'
367
+ else raise_invalid_request("#{file_extension} is not supported for upload")
368
+ end
369
+
370
+ params[:file] = Faraday::UploadIO.new(filepath, content_type)
371
+ end
372
+ end
373
+
374
+ class ComplianceRequirement < Base::Resource
375
+ def initialize(client, options = nil)
376
+ @_name = 'ComplianceRequirement'
377
+ @_identifier_string = 'compliance_requirement'
378
+ super
379
+ end
380
+
381
+ def to_s
382
+ {
383
+ api_id: @api_id,
384
+ compliance_requirement_id: @compliance_requirement_id,
385
+ country_iso2: @country_iso2,
386
+ number_type: @number_type,
387
+ end_user_type: @end_user_type,
388
+ acceptable_document_types: @acceptable_document_types
389
+ }.delete_if { |key, value| value.nil? }.to_s
390
+ end
391
+ end
392
+
393
+ class ComplianceRequirementsInterface < Base::ResourceInterface
394
+ def initialize(client, resource_list_json = nil)
395
+ @_name = 'ComplianceRequirement'
396
+ @_resource_type = ComplianceRequirement
397
+ @_identifier_string = 'compliance_requirement'
398
+ super
399
+ end
400
+
401
+ # Get a ComplianceRequirement
402
+ # @param [String] compliance_requirement_id
403
+ # @return [ComplianceRequirement] ComplianceRequirement
404
+ def get(compliance_requirement_id)
405
+ valid_param?(:compliance_requirement_id, compliance_requirement_id, [String, Symbol], true)
406
+ perform_get(compliance_requirement_id)
407
+ end
408
+
409
+ # List all ComplianceRequirements
410
+ # @option options [String] :country_iso2
411
+ # @option options [String] :number_type
412
+ # @option options [String] :phone_number
413
+ # @option options [String] :end_user_type
414
+ # A combination of country_iso2, number_type, end_user_type OR
415
+ # phone_number, end_user_type can be used to fetch compliance requirements.
416
+ def list(options = nil)
417
+ valid_param?(:options, options, Hash, true)
418
+
419
+ params = {}
420
+ params_expected = %i[ country_iso2 number_type phone_number ]
421
+ params_expected.each do |param|
422
+ if options.key?(param) &&
423
+ valid_param?(param, options[param], [String, Symbol], false)
424
+ params[param] = options[param]
425
+ end
426
+ end
427
+
428
+ if options.key?(:end_user_type) &&
429
+ valid_param?(:end_user_type, options[:end_user_type].capitalize, [String, Symbol], false, %w[Business Individual])
430
+ params[:end_user_type] = options[:end_user_type].capitalize
431
+ end
432
+
433
+ perform_get_without_identifier(params)
434
+ end
435
+ end
436
+
437
+ class ComplianceApplication < Base::Resource
438
+ def initialize(client, options = nil)
439
+ @_name = 'ComplianceApplication'
440
+ @_identifier_string = 'compliance_application'
441
+ super
442
+ end
443
+
444
+ def to_s
445
+ {
446
+ api_id: @api_id,
447
+ created_at: @created_at,
448
+ compliance_application_id: @compliance_application_id,
449
+ alias: @alias,
450
+ status: @status,
451
+ end_user_id: @end_user_id,
452
+ end_user_type: @end_user_type,
453
+ country_iso2: @country_iso2,
454
+ number_type: @number_type,
455
+ compliance_requirement_id: @compliance_requirement_id,
456
+ documents: @documents,
457
+ }.delete_if { |key, value| value.nil? }.to_s
458
+ end
459
+
460
+ def update(params)
461
+ perform_update(params)
462
+ end
463
+
464
+ def delete
465
+ perform_delete
466
+ end
467
+ end
468
+
469
+ class ComplianceApplicationsInterface < Base::ResourceInterface
470
+ def initialize(client, resource_list_json = nil)
471
+ @_name = 'ComplianceApplication'
472
+ @_resource_type = ComplianceApplication
473
+ @_identifier_string = 'compliance_application'
474
+ super
475
+ end
476
+
477
+ # Get a ComplianceApplication
478
+ # @param [String] compliance_application_id
479
+ # @return [ComplianceApplication] ComplianceApplication
480
+ def get(compliance_application_id)
481
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
482
+ perform_get(compliance_application_id)
483
+ end
484
+
485
+ # List all ComplianceApplications
486
+ # @option options [Hash] :options
487
+ # @option options [Int] :offset
488
+ # @option options [Int] :limit
489
+ # @return [Hash]
490
+ def list(options = nil)
491
+ return perform_list if options.nil?
492
+ valid_param?(:options, options, Hash, true)
493
+
494
+ params = {}
495
+ params_expected = %i[ end_user_id country_iso2 number_type status ]
496
+ params_expected.each do |param|
497
+ if options.key?(param) &&
498
+ valid_param?(param, options[param], [String, Symbol], false)
499
+ params[param] = options[param]
500
+ end
501
+ end
502
+
503
+ if options.key?(:end_user_type) &&
504
+ valid_param?(:end_user_type, options[:end_user_type].capitalize, [String, Symbol], false, %w[Business Individual])
505
+ params[:end_user_type] = options[:end_user_type].capitalize
506
+ end
507
+
508
+ if options.key?(:alias) && valid_param?(:alias, options[:alias],[String, Symbol], false)
509
+ params[:alias] = options[:alias]
510
+ end
511
+
512
+ %i[offset limit].each do |param|
513
+ if options.key?(param) && valid_param?(param, options[param],
514
+ [Integer], true)
515
+ params[param] = options[param]
516
+ end
517
+ end
518
+
519
+ raise_invalid_request("Offset can't be negative") if options.key?(:offset) && options[:offset] < 0
520
+
521
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
522
+ raise_invalid_request('The maximum number of results that can be '\
523
+ "fetched is 20. limit can't be more than 20 or less than 1")
524
+ end
525
+
526
+ perform_list(params)
527
+ end
528
+
529
+ # Create a ComplianceApplication
530
+ # @param [String] compliance_requirement_id
531
+ # @param [String] end_user_id
532
+ # @param [String] alias_
533
+ # @param [Array] document_ids
534
+ # @param [String] end_user_type
535
+ # @param [String] country_iso2
536
+ # @param [String] number_type
537
+ # @return [ComplianceApplication] ComplianceApplication
538
+ def create(compliance_requirement_id: nil, end_user_id: nil, alias_: nil,
539
+ document_ids: nil,
540
+ end_user_type: nil,
541
+ country_iso2: nil,
542
+ number_type: nil
543
+ )
544
+ valid_param?(:compliance_requirement_id, compliance_requirement_id, [String, Symbol], false)
545
+ valid_param?(:end_user_id, end_user_id, [String, Symbol], false)
546
+ valid_param?(:alias_, alias_, [String, Symbol], false)
547
+ valid_param?(:country_iso2, country_iso2, [String, Symbol], false)
548
+ valid_param?(:number_type, number_type, [String, Symbol], false)
549
+ valid_param?(:document_ids, document_ids, [Array], false)
550
+ if !document_ids.nil?
551
+ document_ids.each do |document_id|
552
+ valid_param?(:document_id, document_id, [String, Symbol], true)
553
+ end
554
+ end
555
+
556
+ if !end_user_type.nil?
557
+ end_user_type = end_user_type.downcase
558
+ valid_param?(:end_user_type, end_user_type, [String, Symbol], false, %w[business individual])
559
+ end
560
+
561
+ params = {
562
+ compliance_requirement_id: compliance_requirement_id,
563
+ end_user_id: end_user_id,
564
+ end_user_type: end_user_type,
565
+ country_iso2: country_iso2,
566
+ number_type: number_type,
567
+ document_ids: document_ids,
568
+ alias: alias_
569
+ }.delete_if { |key, value| value.nil? }
570
+
571
+ perform_create(params, false)
572
+ end
573
+
574
+ # Update a ComplianceApplication
575
+ # @param [String] compliance_application_id
576
+ # @param [Array] document_ids
577
+ # @return [ComplianceApplication] ComplianceApplication
578
+ def update(compliance_application_id, document_ids)
579
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
580
+ valid_param?(:document_ids, document_ids, [Array], true)
581
+ document_ids.each do |document_id|
582
+ valid_param?(:document_id, document_id, [String, Symbol], true)
583
+ end
584
+
585
+ params = {
586
+ compliance_application_id: compliance_application_id,
587
+ document_ids: document_ids
588
+ }
589
+
590
+ ComplianceApplication.new(@_client,
591
+ resource_id: compliance_application_id).update(params)
592
+ end
593
+
594
+ # Delete a ComplianceApplication
595
+ # @param [String] compliance_application_id
596
+ def delete(compliance_application_id)
597
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
598
+ ComplianceApplication.new(@_client,
599
+ resource_id: compliance_application_id).delete
600
+ end
601
+
602
+ # Submit a ComplianceApplication
603
+ # @param [String] compliance_application_id
604
+ def submit(compliance_application_id)
605
+ valid_param?(:compliance_application_id, compliance_application_id, [String, Symbol], true)
606
+ perform_submit(compliance_application_id)
607
+ end
608
+ end
609
+ end
610
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'resources/messages'
2
+ require_relative 'resources/powerpacks'
3
+ require_relative 'resources/accounts'
4
+ require_relative 'resources/applications'
5
+ require_relative 'resources/recordings'
6
+ require_relative 'resources/pricings'
7
+ require_relative 'resources/numbers'
8
+ require_relative 'resources/conferences'
9
+ require_relative 'resources/calls'
10
+ require_relative 'resources/endpoints'
11
+ require_relative 'resources/addresses'
12
+ require_relative 'resources/identities'
13
+ require_relative 'resources/phlos'
14
+ require_relative 'resources/nodes'
15
+ require_relative 'resources/phlo_member'
16
+ require_relative 'resources/call_feedback'
17
+ require_relative 'resources/media'
18
+ require_relative 'resources/lookup'
19
+ require_relative 'resources/regulatory_compliance'
20
+ require_relative 'resources/multipartycalls'
21
+
22
+ module Plivo
23
+ module Resources
24
+ end
25
+ end
@@ -0,0 +1,63 @@
1
+ require_relative "resources"
2
+ require_relative "base_client"
3
+ require_relative "base"
4
+
5
+ module Plivo
6
+ class RestClient < BaseClient
7
+
8
+ # Resources
9
+ attr_reader :messages, :account, :subaccounts, :recordings
10
+ attr_reader :pricings, :numbers, :calls, :conferences
11
+ attr_reader :phone_numbers, :applications, :endpoints, :multipartycalls
12
+ attr_reader :addresses, :identities
13
+ attr_reader :call_feedback
14
+ attr_reader :powerpacks
15
+ attr_reader :powerpacks, :media
16
+ attr_reader :lookup
17
+ attr_reader :end_users
18
+ attr_reader :compliance_document_types, :compliance_documents, :compliance_requirements, :compliance_applications
19
+
20
+ def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout = 5)
21
+ configure_base_uri
22
+ super
23
+ configure_interfaces
24
+ end
25
+
26
+ private
27
+
28
+ def configure_base_uri
29
+ @base_uri = Base::PLIVO_API_URL
30
+ @voice_base_uri = Base::API_VOICE
31
+ @voice_base_uri_fallback_1 = Base::API_VOICE_FALLBACK_1
32
+ @voice_base_uri_fallback_2 = Base::API_VOICE_FALLBACK_2
33
+ @callinsights_base_uri = Base::CALLINSIGHTS_API_URL
34
+ @lookup_base_uri = Base::LOOKUP_API_URL
35
+ end
36
+
37
+ def configure_interfaces
38
+ @account = Resources::AccountInterface.new(self)
39
+ @messages = Resources::MessagesInterface.new(self)
40
+ @powerpacks = Resources::PowerpackInterface.new(self)
41
+ @media = Resources::MediaInterface.new(self)
42
+ @subaccounts = Resources::SubaccountInterface.new(self)
43
+ @recordings = Resources::RecordingInterface.new(self)
44
+ @pricings = Resources::PricingInterface.new(self)
45
+ @numbers = Resources::NumberInterface.new(self)
46
+ @phone_numbers = Resources::PhoneNumberInterface.new(self)
47
+ @conferences = Resources::ConferenceInterface.new(self)
48
+ @calls = Resources::CallInterface.new(self)
49
+ @endpoints = Resources::EndpointInterface.new(self)
50
+ @applications = Resources::ApplicationInterface.new(self)
51
+ @addresses = Resources::AddressInterface.new(self)
52
+ @identities = Resources::IdentityInterface.new(self)
53
+ @call_feedback = Resources::CallFeedbackInterface.new(self)
54
+ @multipartycalls = Resources::MultiPartyCallInterface.new( self)
55
+ @lookup = Resources::LookupInterface.new(self)
56
+ @end_users = Resources::EndUsersInterface.new(self)
57
+ @compliance_document_types = Resources::ComplianceDocumentTypesInterface.new(self)
58
+ @compliance_documents = Resources::ComplianceDocumentsInterface.new(self)
59
+ @compliance_requirements = Resources::ComplianceRequirementsInterface.new(self)
60
+ @compliance_applications = Resources::ComplianceApplicationsInterface.new(self)
61
+ end
62
+ end
63
+ end