Class: ConcurConnect::Session

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(consumer_key, consumer_secret, company_id, debug = false) ⇒ Session

Returns a new instance of Session.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/concur_connect/session.rb', line 12

def initialize(consumer_key, consumer_secret, company_id, debug = false)
  self.consumer_key = consumer_key
  self.consumer_secret = consumer_secret
  self.company_id = company_id
  self.debug = debug
  @user_finder = UserFinder.new self
  @expense_report_finder = ExpenseReportFinder.new self

  faraday = Faraday.new(:url => 'https://www.concursolutions.com/api') do |builder|
    builder.request :OAuth, {
      :consumer_key => consumer_key,
      :consumer_secret => consumer_secret
    }
    builder.request  :url_encoded
    builder.request  :json
    builder.response :logger if debug?
    builder.adapter  :net_http

    builder.use Faraday::Response::ParseXml
  end
  __setobj__ faraday  # wrap Faraday in a loving embrace
end

Instance Attribute Details

#company_idObject

Returns the value of attribute company_id.



10
11
12
# File 'lib/concur_connect/session.rb', line 10

def company_id
  @company_id
end

#consumer_keyObject

Returns the value of attribute consumer_key.



10
11
12
# File 'lib/concur_connect/session.rb', line 10

def consumer_key
  @consumer_key
end

#consumer_secretObject

Returns the value of attribute consumer_secret.



10
11
12
# File 'lib/concur_connect/session.rb', line 10

def consumer_secret
  @consumer_secret
end

#debugObject Also known as: debug?

Returns the value of attribute debug.



10
11
12
# File 'lib/concur_connect/session.rb', line 10

def debug
  @debug
end

Instance Method Details

#expense_reports(date, status = 'APPROVED') ⇒ Object



40
41
42
# File 'lib/concur_connect/session.rb', line 40

def expense_reports(date, status = 'APPROVED')
  @expense_reports ||= @expense_report_finder.find nil, status, date
end

#user(id) ⇒ Object



36
37
38
# File 'lib/concur_connect/session.rb', line 36

def user(id)
  @user ||= @user_finder.find id
end