Module: FlexmlsApi::Configuration

Included in:
FlexmlsApi, MultiClient
Defined in:
lib/flexmls_api/configuration.rb,
lib/flexmls_api/configuration/yaml.rb

Defined Under Namespace

Classes: YamlConfig

Constant Summary collapse

VALID_OPTION_KEYS =

valid configuration options

[:api_key, :api_secret, :api_user, :endpoint, :user_agent, :version, :ssl, :oauth2_provider, :authentication_mode].freeze
OAUTH2_KEYS =
[:authorization_uri, :access_uri, :client_id, :client_secret,
  # Requirements for authorization_code grant type
  :redirect_uri,  
  # Requirements for password grant type
  :username, :password
]
DEFAULT_API_KEY =
nil
DEFAULT_API_SECRET =
nil
DEFAULT_API_USER =
nil
DEFAULT_ENDPOINT =
'http://api.flexmls.com'
DEFAULT_VERSION =
'v1'
DEFAULT_USER_AGENT =
"flexmls API Ruby Gem #{VERSION}"
DEFAULT_SSL =
false
DEFAULT_OAUTH2 =
nil
X_FLEXMLS_API_USER_AGENT =
"X-flexmlsApi-User-Agent"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



32
33
34
# File 'lib/flexmls_api/configuration.rb', line 32

def self.extended(base)
  base.reset_configuration
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



28
29
30
# File 'lib/flexmls_api/configuration.rb', line 28

def configure
  yield self
end

#optionsObject



36
37
38
39
40
# File 'lib/flexmls_api/configuration.rb', line 36

def options
  VALID_OPTION_KEYS.inject({}) do |opt,key|
    opt.merge(key => send(key))
  end
end

#reset_configurationObject



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/flexmls_api/configuration.rb', line 42

def reset_configuration
  self.api_key     = DEFAULT_API_KEY
  self.api_secret  = DEFAULT_API_SECRET
  self.api_user    = DEFAULT_API_USER
  self.authentication_mode = FlexmlsApi::Authentication::ApiAuth
  self.endpoint    = DEFAULT_ENDPOINT
  self.oauth2_provider = DEFAULT_OAUTH2
  self.user_agent  = DEFAULT_USER_AGENT
  self.ssl         = DEFAULT_SSL
  self.version     = DEFAULT_VERSION
  self
end