Skip to content

Commit

Permalink
adds support for proxy_options when calling Client#_
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmer committed Jul 16, 2024
1 parent 4c9405c commit 8685fc1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/ruby_http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def ratelimit

# A simple REST client.
class Client
attr_reader :host, :request_headers, :url_path, :request, :http
attr_reader :host, :request_headers, :url_path, :request, :http, :proxy_options
# * *Args* :
# - +host+ -> Base URL for the api. (e.g. https://api.sendgrid.com)
# - +request_headers+ -> A hash of the headers you want applied on
Expand Down Expand Up @@ -275,7 +275,8 @@ def _(name = nil)
url_path = name ? @url_path + [name] : @url_path
Client.new(host: @host, request_headers: @request_headers,
version: @version, url_path: url_path,
http_options: @http_options)
http_options: @http_options,
proxy_options: @proxy_options)
end

# Dynamically add segments to the url, then call a method.
Expand Down
12 changes: 11 additions & 1 deletion test/test_ruby_http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ def setup
@host = 'http://localhost:4010'
@version = 'v3'
@http_options = { open_timeout: 60, read_timeout: 60 }
@proxy_options = { host: '127.0.0.1', port: 8080, user: 'anonymous', pass: 'secret'}
@client = MockRequest.new(host: @host,
request_headers: @headers,
version: @version)
@client_with_options = MockRequest.new(host: @host,
request_headers: @headers,
version: @version,
http_options: @http_options)
http_options: @http_options,
proxy_options: @proxy_options)
end

def test_init
Expand Down Expand Up @@ -266,6 +268,14 @@ def test__
assert_equal(['test'], url1.url_path)
end

def test___with_client_with_options
url1 = @client_with_options._('test')
assert_equal(['test'], url1.url_path)
assert_equal(@host, url1.host)
assert_equal(@headers, url1.request_headers)
assert_equal(@proxy_options, url1.proxy_options)
end

def test_ratelimit_core
expiry = Time.now.to_i + 1
rl = SendGrid::Response::Ratelimit.new(500, 100, expiry)
Expand Down

0 comments on commit 8685fc1

Please sign in to comment.