Module: YellowApi::Config
- Included in:
- YellowApi
- Defined in:
- lib/yellow_api/config.rb
Overview
Defines constants for default configuration
Constant Summary
- 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"- 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"- 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"- VALID_OPTIONS_KEYS =
Keys which can be configured
[ :apikey, :endpoint, :sandbox_endpoint, :sandbox_enabled, :fmt ]
Class Method Summary (collapse)
-
+ (Object) extend(base)
When this module is extended, set all configurations back to defaults.
Instance Method Summary (collapse)
-
- (Object) configure {|_self| ... }
Allows configuration options to be set in a block.
-
- (Object) options
Create a hash of options and their values.
-
- (Object) reset
Reset all configurations back to defaults.
Class Method Details
+ (Object) extend(base)
When this module is extended, set all configurations back to defaults
43 44 45 |
# File 'lib/yellow_api/config.rb', line 43 def self.extend(base) base.reset end |
Instance Method Details
- (Object) configure {|_self| ... }
Allows configuration options to be set in a block
48 49 50 51 |
# File 'lib/yellow_api/config.rb', line 48 def configure yield self self end |
- (Object) options
Create a hash of options and their values
54 55 56 57 58 59 60 |
# File 'lib/yellow_api/config.rb', line 54 def = {} VALID_OPTIONS_KEYS.each do |k| [k] = send(k) end end |
- (Object) reset
Reset all configurations back to defaults
63 64 65 66 67 68 69 |
# File 'lib/yellow_api/config.rb', line 63 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 end |