vonage 7.7.1 → 7.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5abd23c1c0bb97e8cb78fc79732f72ea35887914247c9680ad3c2eaa6d0cdc2
4
- data.tar.gz: 9376d57883a348e58082fca9fe7f0fdc22e0f8cc2b459286013a9a44657e7527
3
+ metadata.gz: 4d7253aa212d9f85a8dc7e53da784d9277d5c1ef56b554b558967d19e2358a6a
4
+ data.tar.gz: 3c7882f459e88fcc1576c9c93e86908db09d405995f3d4908f5ba299c2558257
5
5
  SHA512:
6
- metadata.gz: c2a2dc7f2a936dc09a1548df697d66bc894dba2ec6835bd01a01927de19fe06fc0d8f41a5acd5f241591ae2d6e6fd91c01d14c1bab2f12d11626578bb9a7a365
7
- data.tar.gz: da5dbce2fa961f5f5fa50812900f3ff563b7a34f1b407a5f64f94f43446c5dd23e8a265962499b9a1f7d055e46100cdcf5af76772fce513a1fe3accc1c2a5122
6
+ metadata.gz: b97ccb9cbc712896509d5910074592c3a545049e94c4168b5b2a997f5ffcc760054e2ca9b3ef05c33a19e530fe1aec59694b5e741042076e7c6a3f1de51788b9
7
+ data.tar.gz: c93e485c0410b15454c2c984d323f087efd2f3d28d768ba7e5e1e51aee89fefe3eaa635aaeea72a8acd9e90cf4fe2d207ecdf2a7ffa396b9345b20c580a6804c
data/lib/vonage/logger.rb CHANGED
@@ -18,7 +18,7 @@ module Vonage
18
18
  def_delegator :@logger, name, name
19
19
  end
20
20
 
21
- sig { params(request: T.any(Net::HTTP::Post, Net::HTTP::Get, Net::HTTP::Delete, Net::HTTP::Put)).void }
21
+ sig { params(request: T.any(Net::HTTP::Post, Net::HTTP::Get, Net::HTTP::Delete, Net::HTTP::Put, Net::HTTP::Patch)).void }
22
22
  def log_request_info(request)
23
23
  @logger = T.let(@logger, T.nilable(T.any(::Logger, Vonage::Logger)))
24
24
 
@@ -109,7 +109,7 @@ module Vonage
109
109
  response = make_request!(request, &block)
110
110
 
111
111
  if auto_advance
112
- iterable_request(path, response: response, response_class: response_class, &block)
112
+ iterable_request(path, response: response, response_class: response_class, params: params, &block)
113
113
  else
114
114
  return if block
115
115
 
@@ -117,7 +117,7 @@ module Vonage
117
117
  end
118
118
  end
119
119
 
120
- def iterable_request(path, response: nil, response_class: nil, &block)
120
+ def iterable_request(path, response: nil, response_class: nil, params: {}, &block)
121
121
  json_response = ::JSON.parse(response.body)
122
122
  response = parse(response, response_class)
123
123
  remainder = remaining_count(json_response)
@@ -40,11 +40,11 @@ module Vonage
40
40
  #
41
41
  # @option params [Integer] :index
42
42
  # Page index.
43
- #
43
+ #
44
44
  # @option params [Boolean] :auto_advance
45
45
  # Set this to `true` to auto-advance through all the pages in the record
46
46
  # and collect all the data. The default is `false`.
47
- #
47
+ #
48
48
  # @param [Hash] params
49
49
  #
50
50
  # @return [ListResponse]
@@ -92,7 +92,7 @@ module Vonage
92
92
  # @option params [Boolean] :auto_advance
93
93
  # Set this to `true` to auto-advance through all the pages in the record
94
94
  # and collect all the data. The default is `false`.
95
- #
95
+ #
96
96
  # @param [Hash] params
97
97
  #
98
98
  # @return [ListResponse]
@@ -200,5 +200,29 @@ module Vonage
200
200
  def update(params)
201
201
  request('/number/update', params: camelcase(params), type: Post, response_class: Response)
202
202
  end
203
+
204
+ private
205
+
206
+ # A specific implementation of iterable_request for Numbers, because the Numbers API
207
+ # handles pagination differently to other Vonage APIs
208
+ def iterable_request(path, response: nil, response_class: nil, params: {}, &block)
209
+ response = parse(response, response_class)
210
+ params[:index] = 1 unless params.has_key?(:index)
211
+ size = params.fetch(:size, 10)
212
+ count_from_index = response[:count] - ((params[:index] - 1) * size)
213
+
214
+ while count_from_index > response.numbers.size
215
+ params[:index] += 1
216
+ request = build_request(path: path, type: Get, params: params)
217
+
218
+ # Make request...
219
+ paginated_response = make_request!(request)
220
+ next_response = parse(paginated_response, response_class)
221
+
222
+ response.numbers.push(*next_response.numbers)
223
+ end
224
+
225
+ response
226
+ end
203
227
  end
204
228
  end
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = '7.7.1'
4
+ VERSION = '7.7.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.7.1
4
+ version: 7.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-02 00:00:00.000000000 Z
11
+ date: 2022-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nexmo-jwt