Skip to content

Commit 1da4ee6

Browse files
authored
Merge branch 'main' into devx-8749-add-verify-custom-templates
2 parents c22303f + 68ff52b commit 1da4ee6

File tree

5 files changed

+48
-9
lines changed

5 files changed

+48
-9
lines changed

Diff for: CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 7.27.1
2+
3+
* Fixes a bug with setting options on the HTTP client. [#319](https://github.com/Vonage/vonage-ruby-sdk/pull/319)
4+
15
# 7.27.0
26

37
* Updates Messages API implementation to add RCS channel as well as a new `PATCH` endpoint for RCS message revocation and WhatsApp Mark as Read features. [#316](https://github.com/Vonage/vonage-ruby-sdk/pull/316)

Diff for: README.md

+28
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ need a Vonage account. Sign up [for free at vonage.com][signup].
1414
* [Logging](#logging)
1515
* [Exceptions](#exceptions)
1616
* [Overriding the default hosts](#overriding-the-default-hosts)
17+
* [HTTP Client Configuration](#http-client-configuration)
1718
* [JWT authentication](#jwt-authentication)
1819
* [Webhook signatures](#webhook-signatures)
1920
* [Pagination](#pagination)
@@ -179,6 +180,33 @@ client = Vonage::Client.new(
179180

180181
By default the hosts are set to `api.nexmo.com` and `rest.nexmo.com`, respectively.
181182

183+
### HTTP Client Configuration
184+
185+
It is possible to set configuration options on the HTTP client. This can be don in a couple of ways.
186+
187+
1. Using an `:http` key during `Vonage::Client` instantiation, for example:
188+
```ruby
189+
client = Vonage::Client.new(
190+
api_key: 'YOUR-API-KEY',
191+
api_secret: 'YOUR-API-SECRET',
192+
http: {
193+
max_retries: 1
194+
}
195+
)
196+
```
197+
198+
2. By using the `http=` setter on the `Vonage::Config` object, for example:
199+
```ruby
200+
client = Vonage::Client.new(
201+
api_key: 'YOUR-API-KEY',
202+
api_secret: 'YOUR-API-SECRET'
203+
)
204+
205+
client.config.http = { max_retries: 1 }
206+
```
207+
208+
The Vonage Ruby SDK uses the [`Net::HTTP::Persistent` library](https://github.com/drbrain/net-http-persistent) as an HTTP client. For available configuration options see [the documentation for that library](https://www.rubydoc.info/gems/net-http-persistent/3.0.0/Net/HTTP/Persistent).
209+
182210
### Webhook signatures
183211

184212
Certain Vonage APIs provide signed [webhooks](https://developer.vonage.com/en/getting-started/concepts/webhooks) as a means of verifying the origin of the webhooks. The exact signing mechanism varies depending on the API.

Diff for: lib/vonage/http.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# typed: strict
22
# frozen_string_literal: true
3-
require 'net/http'
3+
require 'net/http/persistent'
44

55
module Vonage
66
module HTTP
@@ -21,7 +21,7 @@ def initialize(hash)
2121
end
2222
end
2323

24-
sig { params(http: Net::HTTP).returns(T::Hash[Symbol, T.untyped]) }
24+
sig { params(http: Net::HTTP::Persistent).returns(T::Hash[Symbol, T.untyped]) }
2525
def set(http)
2626
@hash.each do |name, value|
2727
http.public_send(defined_options.fetch(name), value)
@@ -34,7 +34,7 @@ def set(http)
3434
def defined_options
3535
@defined_options = T.let(@defined_options, T.nilable(T::Hash[Symbol, T.untyped]))
3636

37-
@defined_options ||= Net::HTTP.instance_methods.grep(/\w=\z/).each_with_object({}) do |name, hash|
37+
@defined_options ||= Net::HTTP::Persistent.instance_methods.grep(/\w=\z/).each_with_object({}) do |name, hash|
3838
hash[name.to_s.chomp('=').to_sym] = name
3939
end
4040
end

Diff for: lib/vonage/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# typed: strong
22

33
module Vonage
4-
VERSION = '7.27.0'
4+
VERSION = '7.27.1'
55
end

Diff for: test/vonage/http_options_test.rb

+12-5
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ def read_timeout
88
5
99
end
1010

11-
def proxy_address
12-
'localhost'
11+
def proxy_host
12+
'example.com'
13+
end
14+
15+
def proxy_port
16+
4567
1317
end
1418

1519
def ca_file
@@ -23,13 +27,16 @@ def test_invalid_option_raises_argument_error
2327
end
2428

2529
def test_set_method
26-
http = Net::HTTP.new('example.com', Net::HTTP.https_default_port, p_addr = nil)
30+
http = Net::HTTP::Persistent.new
31+
32+
proxy = URI::HTTP.build(host: proxy_host, port: proxy_port)
2733

28-
options = Options.new(read_timeout: read_timeout, proxy_address: proxy_address, ca_file: ca_file)
34+
options = Options.new(read_timeout: read_timeout, proxy: proxy, ca_file: ca_file)
2935
options.set(http)
3036

3137
assert_equal read_timeout, http.read_timeout
32-
assert_equal proxy_address, http.proxy_address
38+
assert_equal proxy_host, http.proxy_uri.hostname
39+
assert_equal proxy_port, http.proxy_uri.port
3340
assert_equal ca_file, http.ca_file
3441
end
3542
end

0 commit comments

Comments
 (0)