Module: TeamboxAPI

Defined in:
lib/teambox/teambox-api.rb

Overview

This library is a small wrapper around the REST interface

Defined Under Namespace

Classes: Base, Comment, Error, Project, Task

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.client_idObject

Returns the value of attribute client_id.



15
16
17
# File 'lib/teambox/teambox-api.rb', line 15

def client_id
  @client_id
end

.client_secretObject

Returns the value of attribute client_secret.



15
16
17
# File 'lib/teambox/teambox-api.rb', line 15

def client_secret
  @client_secret
end

.passwordObject

Returns the value of attribute password.



15
16
17
# File 'lib/teambox/teambox-api.rb', line 15

def password
  @password
end

.siteObject

Returns the value of attribute site.



15
16
17
# File 'lib/teambox/teambox-api.rb', line 15

def site
  @site
end

.tokenObject

Returns the value of attribute token.



15
16
17
# File 'lib/teambox/teambox-api.rb', line 15

def token
  @token
end

.usernameObject

Returns the value of attribute username.



15
16
17
# File 'lib/teambox/teambox-api.rb', line 15

def username
  @username
end

Class Method Details

.access_token(master) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/teambox/teambox-api.rb', line 29

def access_token(master)
  @auth_url = '/oauth/token'
  consumer = OAuth2::Client.new(master.client_id,
                                master.client_secret,
                                {:site => master.site})

  begin
    consumer.password.get_token(master.username, master.password, {:scope => 'read_projects write_projects'}).token
  rescue 
    warn "There was an error trying to retrieve OAuth token from teambox"
  end
end

.authenticate(client_id, client_secret, username, password) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/teambox/teambox-api.rb', line 16

def authenticate(client_id, client_secret, username, password)
  @username  = username
  @password  = password
  @site = 'https://teambox.com/'
  @client_id = client_id
  @client_secret = client_secret

  self::Base.user = username
  self::Base.password = password
  self.token = access_token(self)

end

.resourcesObject



49
50
51
# File 'lib/teambox/teambox-api.rb', line 49

def resources
  @resources ||= []
end