lib/hubspot.rb in ruby_hubspot_api-0.1.2.1 vs lib/hubspot.rb in ruby_hubspot_api-0.2
- old
+ new
@@ -17,10 +17,11 @@
end
def configure
yield(config) if block_given?
set_client_headers if config.access_token
+ set_request_timeouts
end
def configured?
return true unless @config.nil?
end
@@ -28,8 +29,21 @@
private
# Set Authorization header on Hubspot::ApiClient when access_token is configured
def set_client_headers
Hubspot::ApiClient.headers 'Authorization' => "Bearer #{config.access_token}"
+ end
+
+ def set_request_timeouts
+ config.timeout && Hubspot::ApiClient.default_timeout(config.timeout)
+ timeouts = %i[open_timeout read_timeout]
+ timeouts << :write_timeout if RUBY_VERSION >= '2.6'
+
+ timeouts.each do |t|
+ timeout = config.send(t)
+ next unless timeout
+
+ Hubspot::ApiClient.send(t, timeout)
+ end
end
end
end