Module: YellowApi::Config
- Included in:
- YellowApi
- Defined in:
- lib/yellow_api/config.rb
Overview
Defines constants for default configuration
Constant Summary collapse
- DEFAULT_APIKEY =
nil- DEFAULT_ENDPOINT =
The endpoint that will be used to connect if none is set and mode is not set to sandbox
'http://api.yellowapi.com'.freeze
- DEFAULT_SANDBOX_ENDPOINT =
The endpoint that will be used to connect if none is set and mode is set to sandbox
'http://api.sandbox.yellowapi.com'.freeze
- DEFAULT_SANDBOX_ENABLED =
Note:
Changing this to be enabled will automatically switch to using the DEFAULT_SANDBOX_ENDPOINT
Sets the configuration for which type of API key is being used
false- DEFAULT_FMT =
Note:
This is currently fixed at JSON, as there is no XML support at this time
Content type of response to be consumed
'JSON'.freeze
- VALID_OPTIONS_KEYS =
Keys which can be configured
[ :apikey, :endpoint, :sandbox_endpoint, :sandbox_enabled, :uid, :fmt ].freeze
Class Method Summary collapse
-
.extend(base) ⇒ Object
When this module is extended, set all configurations back to defaults.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Allows configuration options to be set in a block.
-
#options ⇒ Object
Create a hash of options and their values.
-
#reset ⇒ Object
Reset all configurations back to defaults.
Class Method Details
.extend(base) ⇒ Object
When this module is extended, set all configurations back to defaults
42 43 44 |
# File 'lib/yellow_api/config.rb', line 42 def self.extend(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Allows configuration options to be set in a block
47 48 49 50 |
# File 'lib/yellow_api/config.rb', line 47 def configure yield self self end |
#options ⇒ Object
Create a hash of options and their values
53 54 55 56 57 58 59 |
# File 'lib/yellow_api/config.rb', line 53 def = {} VALID_OPTIONS_KEYS.each do |k| [k] = send(k) end end |
#reset ⇒ Object
Reset all configurations back to defaults
62 63 64 65 66 67 68 69 |
# File 'lib/yellow_api/config.rb', line 62 def reset self.apikey = DEFAULT_APIKEY self.endpoint = DEFAULT_ENDPOINT self.sandbox_endpoint = DEFAULT_SANDBOX_ENDPOINT self.sandbox_enabled = DEFAULT_SANDBOX_ENABLED self.fmt = DEFAULT_FMT self.uid = UUID.new.generate(:compact) end |