From b04f70354e4db892d1794c351971d2ed3530a0e8 Mon Sep 17 00:00:00 2001 From: Gabe Kopley Date: Wed, 31 Jan 2018 11:12:36 -0800 Subject: [PATCH 1/4] Add config option to set HTTP read timeout Fixes #14 --- lib/hello_sign/client.rb | 3 ++- lib/hello_sign/configuration.rb | 3 ++- spec/hello_sign/client_spec.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/hello_sign/client.rb b/lib/hello_sign/client.rb index 4c6d2e0..c3f4ff8 100644 --- a/lib/hello_sign/client.rb +++ b/lib/hello_sign/client.rb @@ -51,7 +51,7 @@ class Client include Api::OAuth include Api::ApiApp - attr_accessor :end_point, :oauth_end_point, :api_version, :user_agent, :client_id, :client_secret, :email_address, :password, :api_key, :auth_token, :logging, :log_level, :proxy_uri, :proxy_user, :proxy_pass + attr_accessor :end_point, :oauth_end_point, :api_version, :user_agent, :client_id, :client_secret, :email_address, :password, :api_key, :auth_token, :logging, :log_level, :proxy_uri, :proxy_user, :proxy_pass, :timeout ERRORS = { 400 => Error::BadRequest, @@ -154,6 +154,7 @@ def make_connection options faraday.request :url_encoded faraday.response :logger, logger if @logging faraday.adapter :net_http + faraday.options[:timeout] = timeout if timeout end if options[:no_auth] elsif auth_token diff --git a/lib/hello_sign/configuration.rb b/lib/hello_sign/configuration.rb index d4abe1e..7904764 100644 --- a/lib/hello_sign/configuration.rb +++ b/lib/hello_sign/configuration.rb @@ -33,7 +33,7 @@ module Configuration DEFAULT_ENDPOINT = 'https://api.hellosign.com' DEFAULT_API_VERSION = '/v3' DEFAULT_OAUTH_ENDPOINT = 'https://app.hellosign.com' - VALID_OPTIONS_KEYS = [:end_point, :oauth_end_point, :api_version, :user_agent, :client_id, :client_secret, :email_address, :password, :api_key, :auth_token, :log_level, :logging, :proxy_uri, :proxy_user, :proxy_pass] + VALID_OPTIONS_KEYS = [:end_point, :oauth_end_point, :api_version, :user_agent, :client_id, :client_secret, :email_address, :password, :api_key, :auth_token, :log_level, :logging, :proxy_uri, :proxy_user, :proxy_pass, :timeout] DEFAULT_USER_AGENT = "hellosign-ruby-sdk/" + HelloSign::VERSION @@ -77,6 +77,7 @@ def reset self.proxy_uri = nil self.proxy_user = nil self.proxy_pass = nil + self.timeout = nil end end end diff --git a/spec/hello_sign/client_spec.rb b/spec/hello_sign/client_spec.rb index 8e43b76..fd834d3 100644 --- a/spec/hello_sign/client_spec.rb +++ b/spec/hello_sign/client_spec.rb @@ -28,7 +28,8 @@ :logging => false, :proxy_uri => 'proxy_uri', :proxy_user => 'proxy_user', - :proxy_pass => 'proxy_pass' + :proxy_pass => 'proxy_pass', + :timeout => 240 } } subject(:client) { HelloSign::Client.new custom_client } From c46bd2a8b5c2e965575968cda2770cbcfa70152a Mon Sep 17 00:00:00 2001 From: Jen Young Date: Fri, 2 Feb 2018 14:49:15 -0800 Subject: [PATCH 2/4] Version bump to 3.6.1 --- lib/hello_sign/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hello_sign/version.rb b/lib/hello_sign/version.rb index 3adc77b..c7d21b5 100644 --- a/lib/hello_sign/version.rb +++ b/lib/hello_sign/version.rb @@ -23,5 +23,5 @@ # module HelloSign - VERSION = '3.6' + VERSION = '3.6.1' end From 7c0e157dcba78b5a40cc3749400a6c65b38a681a Mon Sep 17 00:00:00 2001 From: Jen Young Date: Tue, 13 Feb 2018 10:31:27 -0800 Subject: [PATCH 3/4] Add tests for timeout parameter --- spec/hello_sign/client_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/hello_sign/client_spec.rb b/spec/hello_sign/client_spec.rb index fd834d3..eab6abe 100644 --- a/spec/hello_sign/client_spec.rb +++ b/spec/hello_sign/client_spec.rb @@ -38,6 +38,14 @@ expect(client.send(key)).to eql(custom_client[key]) end end + + it "should create a new HelloSign Client" do + expect(client).to be_an_instance_of(HelloSign::Client) + end + + it "should have 'timeout' as a parameter" do + expect(client.timeout).to eq(240) + end end end @@ -181,3 +189,14 @@ def get_request(key) end end end + + +# def timeout_request +# stub_post('/account/create', 'error').to_timeout +# end +# +# it "times out" do +# p timeout_request +# p "****" +# p timeout_request.response +# end From e97d9a29f87f799a61ef72fe763616f6d5f307d6 Mon Sep 17 00:00:00 2001 From: Jen Young Date: Tue, 13 Feb 2018 10:38:31 -0800 Subject: [PATCH 4/4] Remove comments --- spec/hello_sign/client_spec.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/spec/hello_sign/client_spec.rb b/spec/hello_sign/client_spec.rb index eab6abe..c177f5b 100644 --- a/spec/hello_sign/client_spec.rb +++ b/spec/hello_sign/client_spec.rb @@ -189,14 +189,3 @@ def get_request(key) end end end - - -# def timeout_request -# stub_post('/account/create', 'error').to_timeout -# end -# -# it "times out" do -# p timeout_request -# p "****" -# p timeout_request.response -# end