Class: Twelve::Connection

Inherits:
Faraday::Connection
  • Object
show all
Defined in:
lib/twelve/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token = nil) ⇒ Connection

Instantiates connection, requires an access_token

access_token - String of the access token



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/twelve/connection.rb', line 13

def initialize(access_token=nil)
  @access_token = access_token

  super('https://secure.gaug.es') do |builder|
    builder.request   :url_encoded
    builder.use       Faraday::Response::ParseJson
    builder.adapter   Faraday.default_adapter
  end

  self.headers["X-Gauges-Token"] = "#{access_token}" if access_token
  self.headers["Accept"] = 'application/json'
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



7
8
9
# File 'lib/twelve/connection.rb', line 7

def access_token
  @access_token
end