Class: CoreLibrary::HttpClientConfiguration

Inherits:
ClientConfiguration
  • Object
show all
Defined in:
lib/apimatic-core/http/configurations/http_client_configuration.rb

Overview

Configuration for an HttpClient.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection: nil, adapter: :net_http_persistent, timeout: 60, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, cache: false, verify: true, http_callback: nil, http_client: nil, logging_configuration: nil) ⇒ HttpClientConfiguration

Initializes a new instance of HttpClientConfiguration.

Parameters:

  • connection (defaults to: nil)

    Connection information

  • adapter (defaults to: :net_http_persistent)

    Adapter configuration

  • timeout (Integer) (defaults to: 60)

    Timeout value

  • max_retries (Integer) (defaults to: 0)

    Max retries values

  • retry_interval (Integer) (defaults to: 1)

    Retry interval value, in seconds

  • backoff_factor (Integer) (defaults to: 2)

    Backoff factor

  • retry_statuses (Array) (defaults to: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524])

    An integer array of http status codes

  • retry_methods (Hash) (defaults to: %i[get put],)

    A string array of methods

  • cache (Boolean) (defaults to: false)

    Should cache be enabled

  • verify (Boolean) (defaults to: true)

    Should verification be enabled.

  • http_callback (defaults to: nil)

    A method to be used as http callback

  • http_client (HttpClient) (defaults to: nil)

    An instance of HttpClient



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/apimatic-core/http/configurations/http_client_configuration.rb', line 19

def initialize(
  connection: nil, adapter: :net_http_persistent, timeout: 60,
  max_retries: 0, retry_interval: 1, backoff_factor: 2,
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
  retry_methods: %i[get put], cache: false, verify: true, http_callback: nil, http_client: nil,
  logging_configuration: nil
)
  @response_factory = HttpResponseFactory.new
  @connection = connection
  @adapter = adapter
  @retry_interval = retry_interval
  @http_callback = http_callback
  @timeout = timeout
  @max_retries = max_retries
  @backoff_factor = backoff_factor
  @retry_statuses = retry_statuses
  @retry_methods = retry_methods
  @verify = verify
  @cache = cache
  @http_client = http_client
  @logging_configuration = logging_configuration
end

Instance Attribute Details

#http_callbackObject (readonly)

Returns the value of attribute http_callback.



4
5
6
# File 'lib/apimatic-core/http/configurations/http_client_configuration.rb', line 4

def http_callback
  @http_callback
end

#http_clientObject (readonly)

Returns the value of attribute http_client.



4
5
6
# File 'lib/apimatic-core/http/configurations/http_client_configuration.rb', line 4

def http_client
  @http_client
end

#logging_configurationObject (readonly)

Returns the value of attribute logging_configuration.



4
5
6
# File 'lib/apimatic-core/http/configurations/http_client_configuration.rb', line 4

def logging_configuration
  @logging_configuration
end

Instance Method Details

#set_http_client(http_client) ⇒ Object

Setter for http_client.



43
44
45
# File 'lib/apimatic-core/http/configurations/http_client_configuration.rb', line 43

def set_http_client(http_client)
  @http_client = http_client
end