Module: Teamwork::Client::Account

Included in:
Teamwork::Client
Defined in:
lib/teamwork/client/account.rb

Instance Method Summary collapse

Instance Method Details

#account_infoObject

GET the authenticated users’s information Return Teamwork::Thing



10
11
12
# File 'lib/teamwork/client/account.rb', line 10

def 
  object_from_response(:get, "account", "account")
end

#authenticate(api_key) ⇒ Object

GET an authenticated user This part is unique to the rest of the lib in that it uses a different path for the API call. What we can get from this, however, is the subdomain that the user is a part of and store that for future API calls. authenticate.teamworkpm.net/authenticate.json Return Teamwork::Thing (or 401 if auth fails)



21
22
23
24
25
26
27
28
29
# File 'lib/teamwork/client/account.rb', line 21

def authenticate(api_key)
  Teamwork.api_key = api_key
  result = connection("http://authenticate.teamworkpm.net").send(:get, "authenticate.json").env
  return result.status if result.status == 401

  thing = Thing.new(result.body["account"])
  Teamwork.subdomain = thing.code
  thing
end