Class: Databasedotcom::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/databasedotcom-oauth2.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_token(token, api_version) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/databasedotcom-oauth2.rb', line 34

def self.from_token(token, api_version)
  client = nil
  unless token.nil?
    client = self.new({
      :client_id     => token.client.id, 
      :client_secret => token.client.secret, 
      :host          => Databasedotcom.parse_domain(token.client.site)
    })
    m = token["id"].match(/\/id\/([^\/]+)\/([^\/]+)$/)
    client.org_id        = m[1] rescue nil
    client.user_id       = m[2] rescue nil
    client.version       = api_version
    client.instance_url  = token.client.site
    client.oauth_token   = token.token
    client.refresh_token = token.refresh_token
  end
  client
end

Instance Method Details

#org_id=(val) ⇒ Object



53
54
55
# File 'lib/databasedotcom-oauth2.rb', line 53

def org_id=(val)
  @org_id = val
end

#user_id=(val) ⇒ Object



57
58
59
# File 'lib/databasedotcom-oauth2.rb', line 57

def user_id=(val)
  @user_id = val
end