Module: BigcommerceOAuthAPI::Configuration

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

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
    :store_hash,
    :endpoint,
    :adapter,
    :client_id,
    :access_token,
    :format,
    :if_modified_since,
    # legacy authentication
    :user_name,
    :api_key
].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_USER_NAME =
nil
DEFAULT_API_KEY =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



31
32
33
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 31

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



47
48
49
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 47

def configure
  yield self
end

#optionsObject

Return the configuration values set in this module



52
53
54
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 52

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

#resetObject



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/bigcommerce-oauth-api/configuration.rb', line 35

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.user_name = DEFAULT_USER_NAME
  self.api_key = DEFAULT_API_KEY
end