plivo 4.3.3 → 4.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 504b141117cfbd9ffc076c66e3e02ff8dd962648
4
- data.tar.gz: c4874e55c3f11321dfdb19ed00e37a5394a75a65
3
+ metadata.gz: 5962f4f0c724be4b4041d248880aef8e05583a8f
4
+ data.tar.gz: 5fa933a52d9bd3cd1cdcb1883b17d9522a5e52a9
5
5
  SHA512:
6
- metadata.gz: a4b984f5f38711bace19f6700a4b7715ae82cd6d12e43d3e734f258451908365ea7cc7d30092739bc583376bb85032b973592bcb2ba15b2cc4c3b3a16a942748
7
- data.tar.gz: 1e334d8825c60460a34034557d47a3aeaf2bca6df3c608d5eb0904fea8675f4a9f616efaaaa9eab1524c07d73472d35ad5bdad8bc4343f7d245a37fef46f84c6
6
+ metadata.gz: 980c62fc69181eaee7b55e75aea5ec3bb4760fdc557e731806b16066df14cafedf10dc8c2218b3ed166843ee5a5867fefe2e622ca84fefcae02b89de5c5b8ee5
7
+ data.tar.gz: 7359e55b9abd47381150463df81d3b98f3d1ff930b653e26a159e7bb1943db3a17184ceb883ace145790e5547f976292c329c633334c903dfae24b4b88ec759a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Change Log
2
2
 
3
+ ## [4.3.4](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.4) (2019-12-20)
4
+ - Add Powerpack support
5
+
3
6
  ## [4.3.3](https://github.com/plivo/plivo-ruby/releases/tag/v4.3.3) (2019-12-04)
4
7
  - Add MMS support
5
8
 
data/README.md CHANGED
@@ -8,7 +8,7 @@ The Plivo Ruby SDK makes it simpler to integrate communications into your Ruby a
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'plivo', '>= 4.3.3'
11
+ gem 'plivo', '>= 4.3.4'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -71,14 +71,32 @@ module Plivo
71
71
  self
72
72
  end
73
73
 
74
+ def perform_custome_action(action = nil, method = 'GET', params = nil, parse = false)
75
+ resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
76
+ response = @_client.send_request(resource_path, method, params)
77
+ parse ? parse_and_set(response) : self
78
+ method == 'POST' ? parse_and_set(params) : self
79
+ self
80
+ end
81
+
74
82
  def perform_action_apiresponse(action = nil, method = 'GET', params = nil, parse = false)
75
83
  resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
76
84
  response = @_client.send_request(resource_path, method, params)
77
85
  parse ? parse_and_set(response) : self
78
86
  method == 'POST' ? parse_and_set(params) : self
87
+ method == 'DELETE' ? parse_and_set(params) : self
79
88
  return response
80
89
  end
81
-
90
+
91
+ def perform_custom_action_apiresponse(action = nil, method = 'GET', params = nil, parse = false)
92
+ resource_path = action ? '/v1/Account/' + @_client.auth_id + '/'+ action + '/' : @_resource_uri
93
+ response = @_client.send_request(resource_path, method, params)
94
+ parse ? parse_and_set(response) : self
95
+ method == 'POST' ? parse_and_set(params) : self
96
+ method == 'DELETE' ? parse_and_set(params) : self
97
+ return response
98
+ end
99
+
82
100
  def perform_delete(params=nil)
83
101
  unless @id
84
102
  raise_invalid_request("Cannot delete a #{@_name} resource "\
@@ -82,6 +82,14 @@ module Plivo
82
82
  objects: @_resource_list
83
83
  }
84
84
  end
85
+
86
+ def perform_action(action = nil, method = 'GET', params = nil, parse = false)
87
+ resource_path = action ? @_resource_uri + action + '/' : @_resource_uri
88
+ response = @_client.send_request(resource_path, method, params)
89
+ parse ? parse_and_set(response) : self
90
+ method == 'POST' ? parse_and_set(params) : self
91
+ self
92
+ end
85
93
 
86
94
  def perform_list_without_object(params = nil)
87
95
  response_json = @_client.send_request(@_resource_uri, 'GET', params)
@@ -29,7 +29,7 @@ module Plivo
29
29
  def process_response(method, response)
30
30
  handle_response_exceptions(response)
31
31
  if method == 'DELETE'
32
- if response[:status] != 204
32
+ if !([200, 204].include? response[:status])
33
33
  raise Exceptions::PlivoRESTError, "Resource at #{response[:url]} "\
34
34
  'couldn\'t be deleted'
35
35
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'resources/messages'
2
+ require_relative 'resources/powerpacks'
2
3
  require_relative 'resources/accounts'
3
4
  require_relative 'resources/applications'
4
5
  require_relative 'resources/recordings'
@@ -14,10 +14,6 @@ module Plivo
14
14
  def deleteMedia()
15
15
  perform_action_apiresponse('Media', 'DELETE')
16
16
  end
17
-
18
- def getMedia(media_id)
19
- perform_action_apiresponse('Media/' + media_id + '/', 'GET')
20
- end
21
17
 
22
18
  def to_s
23
19
  {
@@ -0,0 +1,544 @@
1
+ module Plivo
2
+ module Resources
3
+ include Plivo::Utils
4
+
5
+ class Powerpack < Base::Resource
6
+ def initialize(client, options = nil)
7
+ @_name = 'Powerpack'
8
+ @_identifier_string = 'uuid'
9
+ super
10
+ end
11
+
12
+ def numberpool
13
+ number_pool_uuid = getnumberpool_uuid(uuid)
14
+ options = {'number_pool_id' => number_pool_uuid}
15
+ NumberPool.new(@_client, {resource_json: options})
16
+ end
17
+
18
+ def delete(unrent_numbers = false)
19
+ valid_param?(:unrent_numbers, unrent_numbers, [TrueClass, FalseClass],
20
+ false, [true, false])
21
+
22
+ params = {
23
+ :unrent_numbers => unrent_numbers
24
+ }
25
+ perform_action_apiresponse('', 'DELETE', params)
26
+ # perform_delete(params)
27
+ end
28
+
29
+ def update(options = nil)
30
+ valid_param?(:options, options, Hash, true)
31
+ params = {}
32
+ if options.key?(:application_type)
33
+ params[:application_type] = options[:application_type]
34
+ end
35
+
36
+ if options.key?(:application_id)
37
+ params[:application_id] = options[:application_id]
38
+ end
39
+
40
+ if options.key?(:sticky_sender)
41
+ params[:sticky_sender] = options[:sticky_sender]
42
+ end
43
+
44
+ if options.key?(:local_connect)
45
+ params[:local_connect] = options[:local_connect]
46
+ end
47
+ if options.key?(:name)
48
+ params[:name] = options[:name]
49
+ end
50
+ perform_action_apiresponse('', 'POST', params)
51
+ end
52
+
53
+ def list_numbers(options = nil)
54
+ number_pool_uuid = getnumberpool_uuid(uuid)
55
+ return perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number',
56
+ 'GET') if options.nil?
57
+
58
+ params = {}
59
+
60
+ %i[offset limit].each do |param|
61
+ if options.key?(param) && valid_param?(param, options[param],
62
+ [Integer, Integer], true)
63
+ params[param] = options[param]
64
+ end
65
+ end
66
+
67
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
68
+ raise_invalid_request('The maximum number of results that can be '\
69
+ "fetched is 20. limit can't be more than 20 or less than 1")
70
+ end
71
+
72
+ if options.key?(:offset) && options[:offset] < 0
73
+ raise_invalid_request("Offset can't be negative")
74
+ end
75
+
76
+ if options.key?(:starts_with) &&
77
+ valid_param?(:starts_with, options[:starts_with], String, true)
78
+ params[:starts_with] = options[:starts_with]
79
+ end
80
+ if options.key?(:country_iso2) &&
81
+ valid_param?(:country_iso2, options[:country_iso2], String, true)
82
+ params[:country_iso2] = options[:country_iso2]
83
+ end
84
+ if options.key?(:type) &&
85
+ valid_param?(:type, options[:type], String, true)
86
+ params[:type] = options[:type]
87
+ end
88
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number',
89
+ 'GET', params, true)
90
+ end
91
+
92
+ def getnumberpool_uuid(uuid)
93
+ valid_param?(:uuid, uuid, [String, Symbol], true)
94
+ response = perform_action()
95
+ numberpool_path = response.number_pool
96
+ numberpool_array = numberpool_path.split("/")
97
+ numberpool_array[5]
98
+ end
99
+
100
+ def count_numbers(options = nil)
101
+ number_pool_uuid = getnumberpool_uuid(uuid)
102
+ if options.nil?
103
+ response = perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number',
104
+ 'GET')
105
+ meta = response['meta']
106
+ return meta['total_count']
107
+ end
108
+
109
+ params = {}
110
+
111
+ %i[offset limit].each do |param|
112
+ if options.key?(param) && valid_param?(param, options[param],
113
+ [Integer, Integer], true)
114
+ params[param] = options[param]
115
+ end
116
+ end
117
+
118
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
119
+ raise_invalid_request('The maximum number of results that can be '\
120
+ "fetched is 20. limit can't be more than 20 or less than 1")
121
+ end
122
+
123
+ if options.key?(:offset) && options[:offset] < 0
124
+ raise_invalid_request("Offset can't be negative")
125
+ end
126
+
127
+ if options.key?(:starts_with) &&
128
+ valid_param?(:starts_with, options[:starts_with], String, true)
129
+ params[:starts_with] = options[:starts_with]
130
+ end
131
+ if options.key?(:country_iso2) &&
132
+ valid_param?(:country_iso2, options[:country_iso2], String, true)
133
+ params[:country_iso2] = options[:country_iso2]
134
+ end
135
+ if options.key?(:type) &&
136
+ valid_param?(:type, options[:type], String, true)
137
+ params[:type] = options[:type]
138
+ end
139
+ response = perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number',
140
+ 'GET', param, true)
141
+ meta = response['meta']
142
+ return meta['total_count']
143
+ end
144
+
145
+ def find_number(number)
146
+ number_pool_uuid = getnumberpool_uuid(uuid)
147
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
148
+ 'GET')
149
+ end
150
+
151
+ def add_number(number)
152
+ number_pool_uuid = getnumberpool_uuid(uuid)
153
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
154
+ 'POST')
155
+ end
156
+
157
+ def remove_number(number, unrent= false)
158
+ number_pool_uuid = getnumberpool_uuid(uuid)
159
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + number.to_s ,
160
+ 'DELETE', { unrent: unrent }, false)
161
+ end
162
+
163
+
164
+ def list_shortcodes(options = nil)
165
+ number_pool_uuid = getnumberpool_uuid(uuid)
166
+ return perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Shortcode',
167
+ 'GET') if options.nil?
168
+ params = {}
169
+ %i[offset limit].each do |param|
170
+ if options.key?(param) && valid_param?(param, options[param],
171
+ [Integer, Integer], true)
172
+ params[param] = options[param]
173
+ end
174
+ end
175
+
176
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
177
+ raise_invalid_request('The maximum number of results that can be '\
178
+ "fetched is 20. limit can't be more than 20 or less than 1")
179
+ end
180
+
181
+ if options.key?(:offset) && options[:offset] < 0
182
+ raise_invalid_request("Offset can't be negative")
183
+ end
184
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Shortcode',
185
+ 'GET', params)
186
+ end
187
+
188
+ def find_shortcode(shortcode)
189
+ number_pool_uuid = getnumberpool_uuid(uuid)
190
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Shortcode/' + shortcode.to_s ,
191
+ 'GET')
192
+ end
193
+
194
+ def buy_add_number(options = nil)
195
+ number_pool_uuid = getnumberpool_uuid(uuid)
196
+ params = {}
197
+ params[:rent] = true
198
+ if options.key?(:number)
199
+ return perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + options[:number].to_s ,
200
+ 'POST', params)
201
+ end
202
+ if options.key?(:country_iso2).nil?
203
+ raise_invalid_request('country_iso is cannot be empty')
204
+ end
205
+
206
+ %i[offset limit].each do |param|
207
+ if options.key?(param) && valid_param?(param, options[param],
208
+ [Integer, Integer], true)
209
+ params[param] = options[param]
210
+ end
211
+ end
212
+
213
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
214
+ raise_invalid_request('The maximum number of results that can be '\
215
+ "fetched is 20. limit can't be more than 20 or less than 1")
216
+ end
217
+
218
+ if options.key?(:offset) && options[:offset] < 0
219
+ raise_invalid_request("Offset can't be negative")
220
+ end
221
+
222
+ if options.key?(:pattern) &&
223
+ valid_param?(:pattern, options[:pattern], String, true)
224
+ params[:starts_with] = options[:pattern]
225
+ end
226
+ if options.key?(:country_iso2) &&
227
+ valid_param?(:country_iso2, options[:country_iso2], String, true)
228
+ params[:country_iso] = options[:country_iso2]
229
+ end
230
+ if options.key?(:type) &&
231
+ valid_param?(:type, options[:type], String, true)
232
+ params[:type] = options[:type]
233
+ end
234
+
235
+ response = perform_custom_action_apiresponse('PhoneNumber',
236
+ 'GET', params, true)
237
+ numbers = response['objects'][0]['number']
238
+ perform_custom_action_apiresponse('NumberPool/' + number_pool_uuid + '/Number/' + numbers.to_s,
239
+ 'POST', params)
240
+ end
241
+
242
+ def to_s
243
+ {
244
+ name: @name,
245
+ application_type: @application_type,
246
+ application_id: @application_id,
247
+ sticky_sender: @sticky_sender,
248
+ local_connect: @local_connect,
249
+ uuid: @uuid,
250
+ number_pool:@number_pool,
251
+ created_on:@created_on
252
+ }.to_s
253
+ end
254
+ end
255
+ class NumberPool< Base::Resource
256
+ def initialize(client, options = nil)
257
+ @_name = 'Numberpool'
258
+ @_identifier_string = 'number_pool_id'
259
+ super
260
+ end
261
+
262
+ def numbers
263
+ options = {'number_pool_id' => @number_pool_id}
264
+ Numbers.new(@_client, {resource_json:options })
265
+ end
266
+ def shortcodes
267
+ options = {'number_pool_id' => @number_pool_id}
268
+ Shortcode.new(@_client, {resource_json: options})
269
+ end
270
+ end
271
+
272
+ class Numbers < Base::Resource
273
+ def initialize(client, options = nil)
274
+ @_name = 'Numbers'
275
+ @_identifier_string = 'number_pool_id'
276
+ super
277
+ end
278
+
279
+ def list(options = nil)
280
+ return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number',
281
+ 'GET') if options.nil?
282
+
283
+ params = {}
284
+ %i[offset limit].each do |param|
285
+ if options.key?(param) && valid_param?(param, options[param],
286
+ [Integer, Integer], true)
287
+ params[param] = options[param]
288
+ end
289
+ end
290
+
291
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
292
+ raise_invalid_request('The maximum number of results that can be '\
293
+ "fetched is 20. limit can't be more than 20 or less than 1")
294
+ end
295
+
296
+ if options.key?(:offset) && options[:offset] < 0
297
+ raise_invalid_request("Offset can't be negative")
298
+ end
299
+
300
+ if options.key?(:pattern) &&
301
+ valid_param?(:pattern, options[:pattern], String, true)
302
+ params[:starts_with] = options[:pattern]
303
+ end
304
+ if options.key?(:country_iso2) &&
305
+ valid_param?(:country_iso2, options[:country_iso2], String, true)
306
+ params[:country_iso2] = options[:country_iso2]
307
+ end
308
+ if options.key?(:type) &&
309
+ valid_param?(:type, options[:type], String, true)
310
+ params[:type] = options[:type]
311
+ end
312
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number',
313
+ 'GET', params, true)
314
+ end
315
+ def count(options = nil)
316
+ if options.nil?
317
+ response = perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number',
318
+ 'GET')
319
+ meta = response['meta']
320
+ return meta['total_count']
321
+ end
322
+
323
+ params = {}
324
+
325
+ %i[offset limit].each do |param|
326
+ if options.key?(param) && valid_param?(param, options[param],
327
+ [Integer, Integer], true)
328
+ params[param] = options[param]
329
+ end
330
+ end
331
+
332
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
333
+ raise_invalid_request('The maximum number of results that can be '\
334
+ "fetched is 20. limit can't be more than 20 or less than 1")
335
+ end
336
+
337
+ if options.key?(:offset) && options[:offset] < 0
338
+ raise_invalid_request("Offset can't be negative")
339
+ end
340
+
341
+ if options.key?(:pattern) &&
342
+ valid_param?(:pattern, options[:pattern], String, true)
343
+ params[:starts_with] = options[:pattern]
344
+ end
345
+ if options.key?(:country_iso2) &&
346
+ valid_param?(:country_iso2, options[:country_iso2], String, true)
347
+ params[:country_iso2] = options[:country_iso2]
348
+ end
349
+ if options.key?(:type) &&
350
+ valid_param?(:type, options[:type], String, true)
351
+ params[:type] = options[:type]
352
+ end
353
+ response = perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number',
354
+ 'GET', params, true)
355
+ meta = response['meta']
356
+ return meta['total_count']
357
+ end
358
+
359
+ def find(number)
360
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
361
+ 'GET')
362
+ end
363
+
364
+ def add(number)
365
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
366
+ 'POST')
367
+ end
368
+
369
+ def remove(number, unrent= false)
370
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + number.to_s ,
371
+ 'DELETE', { unrent: unrent }, false)
372
+ end
373
+
374
+ def buy_add_number(options = nil)
375
+ params = {}
376
+ params[:rent] = true
377
+ if options.key?(:number)
378
+ return perform_custom_action_apiresponse('NumberPool/' + number_pool_id + '/Number/' + options[:number].to_s ,
379
+ 'POST', params)
380
+ end
381
+ if options.key?(:country_iso2).nil?
382
+ raise_invalid_request('country_iso is cannot be empty')
383
+ end
384
+ params = {}
385
+
386
+ %i[offset limit].each do |param|
387
+ if options.key?(param) && valid_param?(param, options[param],
388
+ [Integer, Integer], true)
389
+ params[param] = options[param]
390
+ end
391
+ end
392
+
393
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
394
+ raise_invalid_request('The maximum number of results that can be '\
395
+ "fetched is 20. limit can't be more than 20 or less than 1")
396
+ end
397
+
398
+ if options.key?(:offset) && options[:offset] < 0
399
+ raise_invalid_request("Offset can't be negative")
400
+ end
401
+
402
+ if options.key?(:pattern) &&
403
+ valid_param?(:pattern, options[:pattern], String, true)
404
+ params[:starts_with] = options[:pattern]
405
+ end
406
+ if options.key?(:country_iso2) &&
407
+ valid_param?(:country_iso2, options[:country_iso2], String, true)
408
+ params[:country_iso] = options[:country_iso2]
409
+ end
410
+ if options.key?(:type) &&
411
+ valid_param?(:type, options[:type], String, true)
412
+ params[:type] = options[:type]
413
+ end
414
+
415
+ response = perform_custom_action_apiresponse('PhoneNumber',
416
+ 'GET', params, true)
417
+ numbers = response['objects'][0]['number']
418
+ params[:rent] = true
419
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Number/' + numbers.to_s,
420
+ 'POST', params)
421
+ end
422
+
423
+ end
424
+
425
+ class Shortcode < Base::Resource
426
+ def initialize(client, options = nil)
427
+ @_name = 'Shortcode'
428
+ @_identifier_string = 'number_pool_id'
429
+ super
430
+ end
431
+ def list(options = nil)
432
+ return perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode',
433
+ 'GET') if options.nil?
434
+ params = {}
435
+ %i[offset limit].each do |param|
436
+ if options.key?(param) && valid_param?(param, options[param],
437
+ [Integer, Integer], true)
438
+ params[param] = options[param]
439
+ end
440
+ end
441
+
442
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
443
+ raise_invalid_request('The maximum number of results that can be '\
444
+ "fetched is 20. limit can't be more than 20 or less than 1")
445
+ end
446
+
447
+ if options.key?(:offset) && options[:offset] < 0
448
+ raise_invalid_request("Offset can't be negative")
449
+ end
450
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode',
451
+ 'GET')
452
+ end
453
+
454
+ def find(shortcode)
455
+ perform_custom_action_apiresponse('NumberPool/' + @number_pool_id + '/Shortcode/' + shortcode.to_s ,
456
+ 'GET')
457
+ end
458
+ end
459
+
460
+ class PowerpackInterface < Base::ResourceInterface
461
+ def initialize(client, resource_list_json = nil)
462
+ @_name = 'Powerpack'
463
+ @_resource_type = Powerpack
464
+ @_identifier_string = 'powerpack'
465
+ super
466
+ end
467
+
468
+ def create(name, options = nil)
469
+ valid_param?(:name, name, [String, Symbol], true)
470
+
471
+ if name.nil?
472
+ raise InvalidRequestError, 'powerpack name cannot be empty'
473
+ end
474
+
475
+
476
+ params = {
477
+ name: name
478
+ }
479
+
480
+ return perform_create(params) if options.nil?
481
+ valid_param?(:options, options, Hash, true)
482
+
483
+ if options.key?(:application_type) &&
484
+ valid_param?(:application_type, options[:application_type], String, true)
485
+ params[:application_type] = options[:application_type]
486
+ end
487
+
488
+ if options.key?(:application_id) &&
489
+ valid_param?(:application_id, options[:application_id], String, true)
490
+ params[:application_id] = options[:application_id]
491
+ end
492
+
493
+ if options.key?(:sticky_sender) &&
494
+ valid_param?(:sticky_sender, options[:sticky_sender], [TrueClass, FalseClass], true)
495
+ params[:sticky_sender] = options[:sticky_sender]
496
+ end
497
+
498
+ if options.key?(:local_connect) &&
499
+ valid_param?(:local_connect, options[:local_connect], [TrueClass, FalseClass], true)
500
+ params[:local_connect] = options[:local_connect]
501
+ end
502
+ perform_create(params)
503
+ end
504
+
505
+ def get(uuid)
506
+ valid_param?(:uuid, uuid, [String, Symbol], true)
507
+ perform_get(uuid)
508
+ end
509
+
510
+ def list(options = nil)
511
+ return perform_list if options.nil?
512
+ params = {}
513
+ %i[offset limit].each do |param|
514
+ if options.key?(param) && valid_param?(param, options[param],
515
+ [Integer, Integer], true)
516
+ params[param] = options[param]
517
+ end
518
+ end
519
+
520
+ if options.key?(:limit) && (options[:limit] > 20 || options[:limit] <= 0)
521
+ raise_invalid_request('The maximum number of results that can be '\
522
+ "fetched is 20. limit can't be more than 20 or less than 1")
523
+ end
524
+
525
+ if options.key?(:offset) && options[:offset] < 0
526
+ raise_invalid_request("Offset can't be negative")
527
+ end
528
+ perform_list(params)
529
+ end
530
+
531
+ def each
532
+ offset = 0
533
+ loop do
534
+ powerpack_list = list(offset: offset)
535
+ powerpack_list[:objects].each { |message| yield message }
536
+ offset += 20
537
+ return unless powerpack_list.length == 20
538
+ end
539
+ end
540
+
541
+ end
542
+ end
543
+
544
+ end
@@ -10,6 +10,7 @@ module Plivo
10
10
  attr_reader :pricings, :numbers, :calls, :conferences
11
11
  attr_reader :phone_numbers, :applications, :endpoints
12
12
  attr_reader :addresses, :identities
13
+ attr_reader :powerpacks
13
14
 
14
15
  def initialize(auth_id = nil, auth_token = nil, proxy_options = nil, timeout=5)
15
16
  configure_base_uri
@@ -26,6 +27,7 @@ module Plivo
26
27
  def configure_interfaces
27
28
  @account = Resources::AccountInterface.new(self)
28
29
  @messages = Resources::MessagesInterface.new(self)
30
+ @powerpacks = Resources::PowerpackInterface.new(self)
29
31
  @subaccounts = Resources::SubaccountInterface.new(self)
30
32
  @recordings = Resources::RecordingInterface.new(self)
31
33
  @pricings = Resources::PricingInterface.new(self)
data/lib/plivo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Plivo
2
- VERSION = '4.3.3'.freeze
2
+ VERSION = '4.3.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plivo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.3
4
+ version: 4.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Plivo SDKs Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2019-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -173,6 +173,7 @@ files:
173
173
  - lib/plivo/resources/nodes.rb
174
174
  - lib/plivo/resources/numbers.rb
175
175
  - lib/plivo/resources/phlos.rb
176
+ - lib/plivo/resources/powerpacks.rb
176
177
  - lib/plivo/resources/pricings.rb
177
178
  - lib/plivo/resources/recordings.rb
178
179
  - lib/plivo/rest_client.rb