Class: Vermonster::Client

Inherits:
Object
  • Object
show all
Includes:
Authentication, Lists, Tasks, Users
Defined in:
lib/vermonster.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Users

#me, #users

Methods included from Tasks

#tasks

Methods included from Lists

#lists

Methods included from Authentication

#authorize_url, #authorized?, #token!, #use_token!

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



14
15
16
17
18
# File 'lib/vermonster.rb', line 14

def initialize(options={})
  @client = options

  self.connect!
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



12
13
14
# File 'lib/vermonster.rb', line 12

def client
  @client
end

Class Method Details

.connectionObject



31
32
33
# File 'lib/vermonster.rb', line 31

def self.connection
  @@connection
end

Instance Method Details

#connect!(token = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/vermonster.rb', line 20

def connect!(token = nil)
  @@connection = Faraday.new(:url => "https://api.cheddarapp.com/v1") do |f|
    f.headers["Authorization"] = "Bearer #{token}" if !token.nil?
    f.request :json
    f.response :json, :content_type => /\bjson$/
    f.adapter Faraday.default_adapter
  end

  self
end