Module: BigcommerceOAuthAPI::Configuration

Included in:
BigcommerceOAuthAPI
Defined in:
lib/bigcommerce-oauth-api/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
    :store_hash,
    :endpoint,
    :client_id,
    :access_token,
    :format,
    :if_modified_since,
    # legacy authentication
    :user_name,
    :api_key,
    # connection / faraday
    :adapter,
    :timeout,
    :open_timeout,
    # library
    :typecast_to_resource
].freeze
DEFAULT_STORE_HASH =
nil
DEFAULT_ENDPOINT =
'https://api.bigcommerce.com/stores'.freeze
DEFAULT_CLIENT_ID =
nil
DEFAULT_ACCESS_TOKEN =
nil
DEFAULT_FORMAT =
:json
DEFAULT_ADAPTER =
Faraday.default_adapter
DEFAULT_IF_MODIFIED_SINCE =
nil
DEFAULT_TYPECAST_TO_RESOURCE =

if set to false then response-objects with be of type Hash.

true
DEFAULT_USER_NAME =
nil
DEFAULT_API_KEY =
nil
DEFAULT_TIMEOUT =
10
DEFAULT_OPEN_TIMEOUT =
10

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



39
40
41
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 39

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



58
59
60
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 58

def configure
  yield self
end

#optionsObject

Return the configuration values set in this module



63
64
65
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 63

def options
  Hash[ * VALID_OPTIONS_KEYS.map { |key| [key, send(key)] }.flatten ]
end

#resetObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 43

def reset
  self.store_hash = DEFAULT_STORE_HASH
  self.endpoint = DEFAULT_ENDPOINT
  self.format = DEFAULT_FORMAT
  self.client_id = DEFAULT_CLIENT_ID
  self.access_token = DEFAULT_ACCESS_TOKEN
  self.adapter = DEFAULT_ADAPTER
  self.if_modified_since = DEFAULT_IF_MODIFIED_SINCE
  self.typecast_to_resource = DEFAULT_TYPECAST_TO_RESOURCE
  self.user_name = DEFAULT_USER_NAME
  self.api_key = DEFAULT_API_KEY
  self.timeout = DEFAULT_TIMEOUT
  self.open_timeout = DEFAULT_OPEN_TIMEOUT
end