vonage 7.4.0 → 7.5.1

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: a62ffd2c9e2a145badeb3e1e232b7959ca2b31c0d7355c1cf804db7e955cb96a
4
- data.tar.gz: 6fa0cae4317a331b4218e3d479bff3b7031145c36386c7d19e94d59dfb9cc927
3
+ metadata.gz: '0058dda59784aa7cfa75fe455daaea8f77996a3a6bb13d0c4e9e9e3f3189d158'
4
+ data.tar.gz: f4f638d8a372169e7753e4be0c9a5569034ae94a003fd3abc4e4810d94d4d8e9
5
5
  SHA512:
6
- metadata.gz: fc3c593e76119e4c74094db945f74da19e0289766752c18f89f5de8491753b983f0d130e02af4be4c6bbb70c0ee0e73d0b626af96c676b86c15b0fdbd62803c2
7
- data.tar.gz: 702152725c3a7a707965e971ba0b4599bac7e62dd842037ad9c4e784d68f0d645c90e203093fff806016cb6efc2f7e5269103f14ba2fe7a1fd255b265bd12ed9
6
+ metadata.gz: 55798156fde3c5cc807a1f1fd9e9e361a76254853fafe314f1c19f687596ebf100f69d9c9791ad31e1e2f22d2c00ddad76ee5e736a39dacfccf0c4d00564f95d
7
+ data.tar.gz: 58a1bbc1bccf731746a5cea98b973db35fc7aa201a263e7ea1f054c47b4fd8163c04a40677086278a07392a6c439d410cd1c85ec3dd4ac3594f1aa913cba01b2
data/lib/vonage/config.rb CHANGED
@@ -200,7 +200,7 @@ module Vonage
200
200
 
201
201
  protected
202
202
 
203
- sig { params(name: Symbol, value: T.nilable(T.untyped)).void }
203
+ sig { params(name: Symbol, value: T.untyped).void }
204
204
  def write_attribute(name, value)
205
205
  public_send(:"#{name}=", value)
206
206
  end
@@ -71,6 +71,7 @@ module Vonage
71
71
 
72
72
  # set headers
73
73
  request['User-Agent'] = UserAgent.string(@config.app_name, @config.app_version)
74
+ request['Accept'] = 'application/json'
74
75
  self.class.request_headers.each do |key, value|
75
76
  request[key] = value
76
77
  end
@@ -25,7 +25,7 @@ module Vonage
25
25
  def basic(params)
26
26
  response = request('/ni/basic/json', params: params)
27
27
 
28
- raise Error, response[:status_message] unless response.status.zero?
28
+ raise ServiceError.new(response: response), response[:status_message] unless response.status.zero?
29
29
 
30
30
  response
31
31
  end
@@ -57,7 +57,7 @@ module Vonage
57
57
  def standard(params)
58
58
  response = request('/ni/standard/json', params: params)
59
59
 
60
- raise Error, response[:status_message] unless response.status.zero?
60
+ raise ServiceError.new(response: response), response[:status_message] unless response.status.zero?
61
61
 
62
62
  response
63
63
  end
@@ -93,7 +93,7 @@ module Vonage
93
93
  def advanced(params)
94
94
  response = request('/ni/advanced/json', params: params)
95
95
 
96
- raise Error, response[:status_message] unless response.status.zero?
96
+ raise ServiceError.new(response: response), response[:status_message] unless response.status.zero?
97
97
 
98
98
  response
99
99
  end
@@ -132,7 +132,7 @@ module Vonage
132
132
  def advanced_async(params)
133
133
  response = request('/ni/advanced/async/json', params: params)
134
134
 
135
- raise Error, response[:status_message] unless response.status.zero?
135
+ raise ServiceError.new(response: response), response[:status_message] unless response.status.zero?
136
136
 
137
137
  response
138
138
  end
@@ -0,0 +1,16 @@
1
+ # typed: strong
2
+
3
+ module Vonage
4
+ class ServiceError < Error
5
+ extend T::Sig
6
+
7
+ sig { returns(Vonage::Response) }
8
+ attr_reader :response
9
+
10
+ sig { params(message: T.nilable(String), response: Vonage::Response).void }
11
+ def initialize(message = nil, response:)
12
+ super(message)
13
+ @response = response
14
+ end
15
+ end
16
+ end
data/lib/vonage/sms.rb CHANGED
@@ -105,7 +105,7 @@ module Vonage
105
105
  response = request('/sms/json', params: hyphenate(params), type: Post)
106
106
 
107
107
  unless response.messages.first.status == '0'
108
- raise Error, response.messages.first[:error_text]
108
+ raise ServiceError.new(response: response), response.messages.first[:error_text]
109
109
  end
110
110
 
111
111
  response
data/lib/vonage/verify.rb CHANGED
@@ -64,7 +64,7 @@ module Vonage
64
64
  def request(params, uri = '/verify/json')
65
65
  response = http_request(uri, params: params, type: Post)
66
66
 
67
- raise Error, response[:error_text] if error?(response)
67
+ raise ServiceError.new(response: response), response[:error_text] if error?(response)
68
68
 
69
69
  response
70
70
  end
@@ -97,7 +97,7 @@ module Vonage
97
97
  def check(params)
98
98
  response = http_request('/verify/check/json', params: params, type: Post)
99
99
 
100
- raise Error, response[:error_text] if error?(response)
100
+ raise ServiceError.new(response: response), response[:error_text] if error?(response)
101
101
 
102
102
  response
103
103
  end
@@ -124,7 +124,7 @@ module Vonage
124
124
  def search(params)
125
125
  response = http_request('/verify/search/json', params: params)
126
126
 
127
- raise Error, response[:error_text] if error?(response)
127
+ raise ServiceError.new(response: response), response[:error_text] if error?(response)
128
128
 
129
129
  response
130
130
  end
@@ -151,7 +151,7 @@ module Vonage
151
151
  def control(params)
152
152
  response = http_request('/verify/control/json', params: params, type: Post)
153
153
 
154
- raise Error, response[:error_text] if error?(response)
154
+ raise ServiceError.new(response: response), response[:error_text] if error?(response)
155
155
 
156
156
  response
157
157
  end
@@ -234,11 +234,11 @@ module Vonage
234
234
  #
235
235
  # @see https://developer.nexmo.com/api/verify#verifyRequestWithPSD2
236
236
  #
237
- sig { params(params: T.untyped, uri: T.untyped).returns(T.any(Vonage::Error, Vonage::Response)) }
237
+ sig { params(params: T.untyped, uri: T.untyped).returns(T.any(Vonage::ServiceError, Vonage::Response)) }
238
238
  def psd2(params, uri = '/verify/psd2/json')
239
239
  response = http_request(uri, params: params, type: Post)
240
240
 
241
- raise Error, response[:error_text] if error?(response)
241
+ raise ServiceError.new(response: response), response[:error_text] if error?(response)
242
242
 
243
243
  response
244
244
  end
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = '7.4.0'
4
+ VERSION = '7.5.1'
5
5
  end
@@ -13,9 +13,11 @@ module Vonage
13
13
  talk: Vonage::Voice::Actions::Talk
14
14
  }
15
15
 
16
- ACTIONS.keys.each do |method|
17
- self.class.send :define_method, method do |attributes|
18
- ACTIONS[method].new(**attributes).action
16
+ class << self
17
+ ACTIONS.keys.each do |method|
18
+ define_method method do |attributes|
19
+ ACTIONS[method].new(**attributes).action
20
+ end
19
21
  end
20
22
  end
21
23
 
@@ -39,4 +41,4 @@ module Vonage
39
41
  actions.flatten!
40
42
  end
41
43
  end
42
- end
44
+ 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.4.0
4
+ version: 7.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nexmo-jwt
@@ -139,6 +139,7 @@ files:
139
139
  - lib/vonage/secrets.rb
140
140
  - lib/vonage/secrets/list_response.rb
141
141
  - lib/vonage/server_error.rb
142
+ - lib/vonage/service_error.rb
142
143
  - lib/vonage/signature.rb
143
144
  - lib/vonage/sms.rb
144
145
  - lib/vonage/tfa.rb
@@ -183,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
184
  - !ruby/object:Gem::Version
184
185
  version: '0'
185
186
  requirements: []
186
- rubygems_version: 3.1.4
187
+ rubygems_version: 3.3.6
187
188
  signing_key:
188
189
  specification_version: 4
189
190
  summary: This is the Ruby Server SDK for Vonage APIs. To use it you'll need a Vonage