vonage 7.4.1 → 7.5.0

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
  SHA256:
3
- metadata.gz: 8a1f06b8ae136e6b1f143c728880b50a76bc977e1126eee9d905dea632d70c8f
4
- data.tar.gz: 457cca5f4c829ccd4a63365935b3b119d49464745f052ede7f973eac38fbcfdf
3
+ metadata.gz: f62613660a4bd7e71b9a11ef299c20bd28296bc5f757ae82db513f667db0b687
4
+ data.tar.gz: 0db9c1d1b20dfff9936d7dd5ec495e7074242556f69461b57c5ef69bd244314b
5
5
  SHA512:
6
- metadata.gz: 30c2ff5cda3bf5132abed93e12f05113c523301f5b1aab5040a9c9f2f82d0baea9a0a0033f500376dc013a57e384fe01bbc83fa89eac31e208c8baab5700906d
7
- data.tar.gz: 42586b2544c38fc72233a01af85130cf5d8e6a7b5385d096cb7fa5e74fec189a8977f051f69a760dcf1264247edf8710e59b00cad4e259207cdb69cd7d686c95
6
+ metadata.gz: 73d49ed457a469c6caf6599b2f712fd035f3cde34daf350ae1ae4c18d510c94a01cf2e23902686c2429cfad066215ea94ef02d846c8ac001fd29a6d52c994867
7
+ data.tar.gz: cb3acb8a05f3e3c4ef773a6fca17731ef58929bda0277bbd54e7bc34c8c0983fbcca73e3efd3ddf68a12d62f9c6743efc3474b40d15e13a83bbdd38025ad730b
@@ -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.1'
4
+ VERSION = '7.5.0'
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.1
4
+ version: 7.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-23 00:00:00.000000000 Z
11
+ date: 2022-03-16 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