vonage 7.32.0 → 7.33.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: 767237040504d75ff4f4e7966e2de52d44eb7b1be47470bb238cde32702892f7
4
- data.tar.gz: 197f6d40f803f60acc37ea8a58dd96fae47666d86eb2b1c7eb1d17f9602b24bb
3
+ metadata.gz: a5b786bdfd6a5142be34fe1400d4e1914b6d6d9ef4b7e15d10a56e88f9bb5250
4
+ data.tar.gz: 5768855f0b0d03e66222694234f257600fa65a4eaf07dc4c0b9ce36471b87807
5
5
  SHA512:
6
- metadata.gz: 07a15f1ae2b57f93ecd509a7d162594cd2e134ee79783ae21855d13c93f85886a3c78b797854c71640e10003275e669101e1cbc0c20e9cc39f031df7c01365b7
7
- data.tar.gz: 8152d4eedc3109a26556fb8249fc192737624532b3b7906305b82587abd9be229dc23b797f05b4cf035cb2283a0f009f10db7227943fd58c62ac72c6d0ed71b9
6
+ metadata.gz: 3596b7759e7dc20c08ea1a127d97519aff481011134db294ac81b01452700757055813b2905d32144ae1977d8daa1d7d391ef1378763360ca3443b117caf7e05
7
+ data.tar.gz: e4a089e502ded233cbfbc0c07a60ae5dffceae4e5c550556f377202b7a4cef3b1e42806c3901b81c1c9763a7dd884ae82e9e80e0ecb016e56d0e9bbaeadf7e3d
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = Basic
10
+
9
11
  self.host = :rest_host
10
12
 
11
13
  # Retrieve your account balance.
@@ -0,0 +1,22 @@
1
+ # typed: true
2
+
3
+ module Vonage
4
+ class BasicAndSignature < AbstractAuthentication
5
+ def update(object, data)
6
+ if @config.authentication_preference == :signature
7
+ return unless object.is_a?(Hash)
8
+
9
+ object['api_key'] = T.must(@config).api_key
10
+ object['timestamp'] =Time.now.to_i.to_s
11
+ signature = Signature.new(@config).generate(object)
12
+ object[:sig] = signature
13
+ else
14
+ return unless object.is_a?(Net::HTTPRequest)
15
+
16
+ object.basic_auth(@config.api_key, @config.api_secret)
17
+ end
18
+ end
19
+ end
20
+
21
+ private_constant :Basic
22
+ end
data/lib/vonage/config.rb CHANGED
@@ -109,6 +109,9 @@ module Vonage
109
109
  sig { returns(T.nilable(String)) }
110
110
  attr_accessor :app_version
111
111
 
112
+ sig { returns(T.nilable(Symbol)) }
113
+ attr_accessor :authentication_preference
114
+
112
115
  # Returns the value of attribute http.
113
116
  #
114
117
  # @return [Vonage::HTTP::Options]
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = BasicAndSignature
10
+
9
11
  sig { params(params: T::Hash[Symbol, T.untyped]).returns(Vonage::Response) }
10
12
  def track_sms(params)
11
13
  request('/conversions/sms', params: hyphenate(params), type: Post)
@@ -10,6 +10,29 @@ module Vonage
10
10
  @config = config
11
11
  end
12
12
 
13
+ # Generate a request signature.
14
+ #
15
+ # @example
16
+ # client = Vonage::Client.new
17
+ # client.config.signature_secret = 'secret'
18
+ # client.config.signature_method = 'sha512'
19
+ # params = {
20
+ # 'api_key' => 'abc123',
21
+ # 'to' => '447900000000',
22
+ # 'from' => '447900000001',
23
+ # 'text' => 'Hello World',
24
+ # 'timestamp' => '1385047698'
25
+ # }
26
+ #
27
+ # sig = client.signature.generate(params)
28
+ #
29
+ # @param [Hash] params
30
+ #
31
+ # @see https://developer.nexmo.com/concepts/guides/signing-messages
32
+ def generate(params, signature_secret: @config.signature_secret, signature_method: @config.signature_method)
33
+ digest(params, signature_secret, signature_method)
34
+ end
35
+
13
36
  # Check webhook request signature.
14
37
  #
15
38
  # @example
@@ -38,7 +61,7 @@ module Vonage
38
61
  private
39
62
 
40
63
  def digest(params, signature_secret, signature_method)
41
- digest_string = params.sort.map { |k, v| "&#{k}=#{v.tr('&=', '_')}" }.join
64
+ digest_string = params.sort.map { |k, v| "&#{k}=#{v.to_s.tr('&=', '_')}" }.join
42
65
 
43
66
  case signature_method
44
67
  when 'md5', 'sha1', 'sha256', 'sha512'
data/lib/vonage/sms.rb CHANGED
@@ -6,6 +6,8 @@ module Vonage
6
6
  extend T::Sig
7
7
  include Keys
8
8
 
9
+ self.authentication = BasicAndSignature
10
+
9
11
  self.host = :rest_host
10
12
 
11
13
  # Send an outbound SMS from your Vonage account.
data/lib/vonage/verify.rb CHANGED
@@ -8,6 +8,8 @@ module Vonage
8
8
 
9
9
  private :http_request
10
10
 
11
+ self.authentication = Basic
12
+
11
13
  # Generate and send a PIN to your user.
12
14
  #
13
15
  # @note You can make a maximum of one Verify request per second.
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
 
3
3
  module Vonage
4
- VERSION = '7.32.0'
4
+ VERSION = '7.33.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vonage
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.32.0
4
+ version: 7.33.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vonage
@@ -137,6 +137,7 @@ files:
137
137
  - lib/vonage/applications/list_response.rb
138
138
  - lib/vonage/authentication_error.rb
139
139
  - lib/vonage/basic.rb
140
+ - lib/vonage/basic_and_signature.rb
140
141
  - lib/vonage/bearer_token.rb
141
142
  - lib/vonage/client.rb
142
143
  - lib/vonage/client_error.rb