Class: Onfleet::Configuration
- Inherits:
-
Object
- Object
- Onfleet::Configuration
- Defined in:
- lib/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#default_timeout ⇒ Object
readonly
Returns the value of attribute default_timeout.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(api_key, base_url = nil, headers = {}) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(api_key, base_url = nil, headers = {}) ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/configuration.rb', line 7 def initialize(api_key, base_url = nil, headers = {}) file = File.read(File.("../../package.json", __FILE__)) package_data = JSON.parse(file) @default_url = 'https://onfleet.com/api/v2' # ACTION: need to figure out how to include API timeout parameter @default_timeout = 70000 @api_key = api_key @base_url = base_url ? base_url : @default_url @version = package_data['version'] @name = package_data['name'] # Default headers included in all API requests headers['Content-Type'] = 'application/json' headers['User-Agent'] = "#{@name}-#{@version}" @headers = headers @auth_validated = Onfleet.validate_authentication(@base_url, @api_key) end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/configuration.rb', line 5 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/configuration.rb', line 5 def base_url @base_url end |
#default_timeout ⇒ Object (readonly)
Returns the value of attribute default_timeout.
5 6 7 |
# File 'lib/configuration.rb', line 5 def default_timeout @default_timeout end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
5 6 7 |
# File 'lib/configuration.rb', line 5 def headers @headers end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/configuration.rb', line 5 def name @name end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/configuration.rb', line 5 def version @version end |