Class: ConcurConnect::UserFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/concur_connect/user_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ UserFinder

Returns a new instance of UserFinder.



7
8
9
# File 'lib/concur_connect/user_finder.rb', line 7

def initialize(session)
  self.session = session
end

Instance Attribute Details

#sessionObject

Returns the value of attribute session.



5
6
7
# File 'lib/concur_connect/user_finder.rb', line 5

def session
  @session
end

Instance Method Details

#build_user(response) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/concur_connect/user_finder.rb', line 19

def build_user(response)
  user = User.new
  user. = response['LoginId']
  user.first_name = response['FirstName']
  user.last_name = response['LastName']
  user.session = session
  user
end

#find(id) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/concur_connect/user_finder.rb', line 11

def find(id)
  response = session.get 'user/v1.0/User' do |g|
    g.headers['X-CompanyDomain'] = session.company_id
    g.headers['X-UserID'] = id
  end
  build_user response.body
end