Class: ConcurConnect::ExpenseFinder

Inherits:
Object
  • Object
show all
Includes:
Finder
Defined in:
lib/concur_connect/expense_finder.rb

Instance Attribute Summary

Attributes included from Finder

#session

Instance Method Summary collapse

Methods included from Finder

#initialize

Instance Method Details

#build_expenses(data) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/concur_connect/expense_finder.rb', line 14

def build_expenses(data)
  list = []
  if data['ExpenseEntriesList'] && data['ExpenseEntriesList']['ExpenseEntrySummary']
    items = data['ExpenseEntriesList']['ExpenseEntrySummary']
    items = [items] unless items.is_a?(Array)
    items.each do |datum|
      expense = Expense.new
      expense.type = datum['ExpenseName']
      expense.amount = datum['TransactionAmount']
      expense.vendor = datum['VendorListName']
      list << expense
    end
  end
  list
end

#find(report_id) ⇒ Object



8
9
10
11
12
# File 'lib/concur_connect/expense_finder.rb', line 8

def find(report_id)
  url = "/api/expense/expensereport/v1.1/report/#{report_id}/entries"
  response = session.get url
  build_expenses response.body
end