Class: ShipitAPI::Config
- Inherits:
-
Object
- Object
- ShipitAPI::Config
- Defined in:
- lib/shipit_api/config.rb
Constant Summary collapse
- BASE_URL =
'https://api.shipit.cl/v/'.freeze
- EXTENSION =
'.json'.freeze
- CONTENT_TYPE =
'application/json'.freeze
- ACCEPT =
'application/vnd.shipit.v'.freeze
Instance Attribute Summary collapse
-
#accept ⇒ Object
Returns the value of attribute accept.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#version ⇒ Object
Returns the value of attribute version.
-
#x_shipit_access_token ⇒ Object
Returns the value of attribute x_shipit_access_token.
-
#x_shipit_email ⇒ Object
Returns the value of attribute x_shipit_email.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ Config
constructor
A new instance of Config.
- #set_version!(version) ⇒ Object
Constructor Details
#initialize(version) ⇒ Config
Returns a new instance of Config.
20 21 22 23 24 25 26 |
# File 'lib/shipit_api/config.rb', line 20 def initialize(version) @extension = EXTENSION @content_type = CONTENT_TYPE @version = version @base_url = BASE_URL @accept = "#{ACCEPT}#{version}" end |
Instance Attribute Details
#accept ⇒ Object
Returns the value of attribute accept.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def accept @accept end |
#base_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def base_url @base_url end |
#content_type ⇒ Object
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def content_type @content_type end |
#headers ⇒ Object
Returns the value of attribute headers.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def headers @headers end |
#version ⇒ Object
Returns the value of attribute version.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def version @version end |
#x_shipit_access_token ⇒ Object
Returns the value of attribute x_shipit_access_token.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def x_shipit_access_token @x_shipit_access_token end |
#x_shipit_email ⇒ Object
Returns the value of attribute x_shipit_email.
8 9 10 |
# File 'lib/shipit_api/config.rb', line 8 def x_shipit_email @x_shipit_email end |
Class Method Details
.settings(version = 2) ⇒ Object
11 12 13 14 |
# File 'lib/shipit_api/config.rb', line 11 def self.settings(version = 2) @settings ||= Config.new(version) @settings.set_version!(version) end |
.setup {|settings| ... } ⇒ Object
16 17 18 |
# File 'lib/shipit_api/config.rb', line 16 def self.setup(&block) yield(settings) if block_given? end |
Instance Method Details
#set_version!(version) ⇒ Object
28 29 30 31 32 |
# File 'lib/shipit_api/config.rb', line 28 def set_version!(version) self.version = version self.accept = "#{ACCEPT}#{version}" self end |