Skip to content

Commit

Permalink
Merge pull request #217 from Mangopay/feature/http-config-improvements
Browse files Browse the repository at this point in the history
SDK config improvements
  • Loading branch information
franck-gautier committed May 17, 2023
2 parents 5bfa5aa + ec502a7 commit 6f5ccaa
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/mangopay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Configuration
attr_accessor :preproduction, :root_url,
:client_id, :client_apiKey,
:temp_dir, :log_file, :http_timeout,
:http_max_retries, :http_open_timeout,
:logger

def preproduction
Expand All @@ -63,7 +64,15 @@ def root_url
end

def http_timeout
@http_timeout || 10000
@http_timeout || 30000
end

def http_max_retries
@http_max_retries || 1
end

def http_open_timeout
@http_open_timeout || 60000
end
end

Expand Down Expand Up @@ -141,7 +150,9 @@ def request(method, url, params={}, filters={}, headers_or_idempotency_key = nil
headers['Idempotency-Key'] = headers_or_idempotency_key if headers_or_idempotency_key != nil
end

res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout, ssl_version: :TLSv1_2) do |http|
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true, :read_timeout => configuration.http_timeout,
:max_retries => configuration.http_max_retries,
:open_timeout => configuration.http_open_timeout, ssl_version: :TLSv1_2) do |http|
req = Net::HTTP::const_get(method.capitalize).new(uri.request_uri, headers)
req.body = JSON.dump(params)
before_request_proc.call(req) if before_request_proc
Expand Down

0 comments on commit 6f5ccaa

Please sign in to comment.