Class: FulfilApi::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/fulfil_api/configuration.rb

Overview

Configuration model for the Fulfil gem.

This model holds configuration settings and provides thread-safe access to these settings.

Constant Summary collapse

DEFAULT_API_VERSION =
"v2"
DEFAULT_REQUEST_OPTIONS =
{ open_timeout: 1, read_timeout: 5, write_timeout: 5, timeout: 5 }.freeze
DEFAULT_CONNECTION_OPTIONS =

Tuning for the persistent (keep-alive) HTTP connection.

max_retries re-enables Ruby's built-in retry for idempotent requests (GET/HEAD/PUT/DELETE/OPTIONS). The net_http_persistent adapter forces it to 0, which means a keep-alive socket the server has already dropped surfaces as a read timeout instead of being transparently retried on a fresh socket. POST is never auto-retried, so this is side-effect safe.

idle_timeout and pool_size are passed through to the underlying Net::HTTP::Persistent connection when set.

{ max_retries: 1 }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Configuration

Initializes the configuration with optional settings.

Parameters:

  • options (Hash, nil) (defaults to: {})

    An optional list of configuration options. Each key in the hash should correspond to a configuration attribute.



31
32
33
34
35
36
37
38
39
# File 'lib/fulfil_api/configuration.rb', line 31

def initialize(options = {})
  # Assigns the optional configuration options
  options.each_pair do |key, value|
    send(:"#{key}=", value) if respond_to?(:"#{key}=")
  end

  # Sets the default options if not provided
  set_default_options
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def access_token
  @access_token
end

#api_versionObject

Returns the value of attribute api_version.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def api_version
  @api_version
end

#connection_optionsObject

Returns the value of attribute connection_options.



10
11
12
# File 'lib/fulfil_api/configuration.rb', line 10

def connection_options
  @connection_options
end

#merchant_idObject

Returns the value of attribute merchant_id.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def merchant_id
  @merchant_id
end

#request_optionsObject

Returns the value of attribute request_options.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def request_options
  @request_options
end

#tplObject

Returns the value of attribute tpl.



9
10
11
# File 'lib/fulfil_api/configuration.rb', line 9

def tpl
  @tpl
end