@@ -5,7 +5,7 @@ class Connection
55 class << self
66 def get_json ( path , opts )
77 url = generate_url ( path , opts )
8- response = get ( url , format : :json , timeout : timeout ( opts ) )
8+ response = get ( url , format : :json , read_timeout : read_timeout ( opts ) , open_timeout : open_timeout ( opts ) )
99 log_request_and_response url , response
1010 handle_response ( response )
1111 end
@@ -14,7 +14,7 @@ def post_json(path, opts)
1414 no_parse = opts [ :params ] . delete ( :no_parse ) { false }
1515
1616 url = generate_url ( path , opts [ :params ] )
17- response = post ( url , body : opts [ :body ] . to_json , headers : { 'Content-Type' => 'application/json' } , format : :json , timeout : timeout ( opts ) )
17+ response = post ( url , { body : opts [ :body ] . to_json , headers : { 'Content-Type' => 'application/json' } , format : :json , read_timeout : read_timeout ( opts ) , open_timeout : open_timeout ( opts ) } )
1818 log_request_and_response url , response , opts [ :body ]
1919 raise ( Hubspot ::RequestError . new ( response ) ) unless response . success?
2020
@@ -29,7 +29,8 @@ def put_json(path, options)
2929 body : options [ :body ] . to_json ,
3030 headers : { "Content-Type" => "application/json" } ,
3131 format : :json ,
32- timeout : timeout ( options )
32+ read_timeout : read_timeout ( options ) ,
33+ open_timeout : open_timeout ( options ) ,
3334 )
3435
3536 log_request_and_response ( url , response , options [ :body ] )
@@ -38,16 +39,20 @@ def put_json(path, options)
3839
3940 def delete_json ( path , opts )
4041 url = generate_url ( path , opts )
41- response = delete ( url , format : :json , timeout : timeout ( opts ) )
42+ response = delete ( url , format : :json , read_timeout : read_timeout ( opts ) , open_timeout : open_timeout ( opts ) )
4243 log_request_and_response url , response , opts [ :body ]
4344 raise ( Hubspot ::RequestError . new ( response ) ) unless response . success?
4445 response
4546 end
4647
4748 protected
4849
49- def timeout ( opts = { } )
50- opts . delete ( :timeout ) || Hubspot ::Config . timeout
50+ def read_timeout ( opts = { } )
51+ opts . delete ( :read_timeout ) || Hubspot ::Config . read_timeout
52+ end
53+
54+ def open_timeout ( opts = { } )
55+ opts . delete ( :open_timeout ) || Hubspot ::Config . open_timeout
5156 end
5257
5358 def handle_response ( response )
0 commit comments