Class: Pindo::HttpClient

Inherits:
Object
  • Object
show all
Defined in:
lib/pindo/client/httpclient.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#baseurlObject

Returns the value of attribute baseurl.



15
16
17
# File 'lib/pindo/client/httpclient.rb', line 15

def baseurl
  @baseurl
end

#request_configObject

Returns the value of attribute request_config.



16
17
18
# File 'lib/pindo/client/httpclient.rb', line 16

def request_config
  @request_config
end

#tokenObject

Returns the value of attribute token.



14
15
16
# File 'lib/pindo/client/httpclient.rb', line 14

def token
  @token
end

Class Method Details

.create_instanceObject



42
43
44
45
46
# File 'lib/pindo/client/httpclient.rb', line 42

def self.create_instance()
    
    con = Faraday.new 
    con
end

.create_instance_with_proxyObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/pindo/client/httpclient.rb', line 18

def self.create_instance_with_proxy()

    # puts body_params.to_json
    proxy_options = {
      uri: ENV['http_proxy'] || ENV['https_proxy'],
      user: ENV['HTTP_PROXY_USER'],
      password: ENV['HTTP_PROXY_PASSWORD']
    }

    retry_options = {
      max: 3,                   # Retry a failed request up to 5 times
      interval: 0.5,            # First retry after 0.5s
      backoff_factor: 2,        # Double the delay for each subsequent retry
      interval_randomness: 0.5, # Specify "jitter" of up to 50% of interval
    }

    con = Faraday.new do |config|
      config.request :retry, retry_options
      config.proxy = proxy_options.compact if proxy_options[:uri]  
    end
    
    con
end