Class: Warden::Salesforce::User

Inherits:
Object
  • Object
show all
Defined in:
lib/warden-salesforce/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token) ⇒ User

Returns a new instance of User.



9
10
11
12
13
14
# File 'lib/warden-salesforce/user.rb', line 9

def initialize(access_token)
  @token         = access_token.token
  @refresh_token = access_token.refresh_token
  @instance_url  = access_token.params['instance_url']
  @raw_info      = access_token.post(access_token['id']).parsed
end

Instance Attribute Details

#instance_urlObject (readonly)

Returns the value of attribute instance_url.



6
7
8
# File 'lib/warden-salesforce/user.rb', line 6

def instance_url
  @instance_url
end

#raw_infoObject (readonly)

Returns the value of attribute raw_info.



7
8
9
# File 'lib/warden-salesforce/user.rb', line 7

def raw_info
  @raw_info
end

#refresh_tokenObject (readonly)

Returns the value of attribute refresh_token.



5
6
7
# File 'lib/warden-salesforce/user.rb', line 5

def refresh_token
  @refresh_token
end

#tokenObject (readonly)

Returns the value of attribute token.



4
5
6
# File 'lib/warden-salesforce/user.rb', line 4

def token
  @token
end

Instance Method Details

#clientObject

Build a databasedotcom client if databasedotcom gem present



21
22
23
24
25
26
27
# File 'lib/warden-salesforce/user.rb', line 21

def client
  Databasedotcom::Client.new.tap do |config|
    config.instance_url  = instance_url
    config.oauth_token   = token
    config.refresh_token = refresh_token
  end
end

#usernameObject



16
17
18
# File 'lib/warden-salesforce/user.rb', line 16

def username
  raw_info['username']
end