Module: AvaTax::Configuration

Included in:
AvaTax
Defined in:
lib/avatax/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :app_name,
  :app_version,
  :machine_name,
  :environment,
  :endpoint,
  :user_agent,
  :username,
  :password,
  :connection_options,
  :logger,
  :custom_logger,
  :custom_logger_options,
  :proxy,
  :faraday_response,
  :response_big_decimal_conversion,
  :log_request_and_response_info
].freeze
DEFAULT_APP_NAME =
nil
DEFAULT_APP_VERSION =
nil
DEFAULT_MACHINE_NAME =
nil
DEFAULT_ENDPOINT =
'https://rest.avatax.com'
DEFAULT_USER_AGENT =
"AvaTax Ruby Gem #{AvaTax::VERSION}".freeze
DEFAULT_USERNAME =
nil
DEFAULT_PASSWORD =
nil
DEFAULT_CONNECTION_OPTIONS =

timeout in seconds

{request: {timeout: 1200}}
DEFAULT_LOGGER =
false
DEFAULT_CUSTOM_LOGGER =
nil
DEFAULT_CUSTOM_LOGGER_OPTIONS =
{}
DEFAULT_PROXY =
nil
DEFAULT_FARADAY_RESPONSE =
false
DEFAULT_RESPONSE_BIG_DECIMAL_CONVERSION =
false
DEFAULT_LOG_REQUEST_AND_RESPONSE_INFO =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

Reset config values when extended



45
46
47
# File 'lib/avatax/configuration.rb', line 45

def self.extended(base)
  base.reset
end

Instance Method Details

#configure {|_self| ... } ⇒ Object

Allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



50
51
52
# File 'lib/avatax/configuration.rb', line 50

def configure
  yield self
end

#optionsObject



54
55
56
57
58
# File 'lib/avatax/configuration.rb', line 54

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#resetObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/avatax/configuration.rb', line 60

def reset
  self.app_name = DEFAULT_APP_NAME
  self.app_version = DEFAULT_APP_VERSION
  self.machine_name = DEFAULT_MACHINE_NAME
  self.endpoint = DEFAULT_ENDPOINT
  self.user_agent = DEFAULT_USER_AGENT
  self.username = DEFAULT_USERNAME
  self.password = DEFAULT_PASSWORD
  self.connection_options = DEFAULT_CONNECTION_OPTIONS
  self.logger = DEFAULT_LOGGER
  self.custom_logger = DEFAULT_CUSTOM_LOGGER
  self.custom_logger_options = DEFAULT_CUSTOM_LOGGER_OPTIONS
  self.proxy = DEFAULT_PROXY
  self.faraday_response = DEFAULT_FARADAY_RESPONSE
  self.response_big_decimal_conversion = DEFAULT_RESPONSE_BIG_DECIMAL_CONVERSION
  self.log_request_and_response_info = DEFAULT_LOG_REQUEST_AND_RESPONSE_INFO
end