Class: Harvest::API::Reports
- Inherits:
-
Base
- Object
- Base
- Harvest::API::Reports
show all
- Defined in:
- lib/harvest/api/reports.rb
Instance Attribute Summary
Attributes inherited from Base
#credentials
Instance Method Summary
(collapse)
Methods inherited from Base
api_model, #initialize
Instance Method Details
- (Object) expenses_by_user(user, start_date, end_date)
25
26
27
28
29
30
|
# File 'lib/harvest/api/reports.rb', line 25
def expenses_by_user(user, start_date, end_date)
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
response = request(:get, credentials, "/people/#{user.to_i}/expenses", :query => query)
Harvest::Expense.parse(response.parsed_response)
end
|
- (Object) projects_by_client(client)
32
33
34
35
|
# File 'lib/harvest/api/reports.rb', line 32
def projects_by_client(client)
response = request(:get, credentials, "/projects?client=#{client.to_i}")
Harvest::Project.parse(response.parsed_response)
end
|
- (Object) time_by_project(project, start_date, end_date, options = {})
5
6
7
8
9
10
11
12
13
|
# File 'lib/harvest/api/reports.rb', line 5
def time_by_project(project, start_date, end_date, options = {})
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
query[:user_id] = options[:user].to_i if options[:user]
query[:billable] = (options[:billable] ? "yes" : "no") unless options[:billable].nil?
query[:updated_since] = options[:updated_since].to_s if options[:updated_since]
response = request(:get, credentials, "/projects/#{project.to_i}/entries", :query => query)
Harvest::TimeEntry.parse(JSON.parse(response.body).map {|h| h["day_entry"]})
end
|
- (Object) time_by_user(user, start_date, end_date, options = {})
15
16
17
18
19
20
21
22
23
|
# File 'lib/harvest/api/reports.rb', line 15
def time_by_user(user, start_date, end_date, options = {})
query = {:from => start_date.strftime("%Y%m%d"), :to => end_date.strftime("%Y%m%d")}
query[:project_id] = options[:project].to_i if options[:project]
query[:billable] = (options[:billable] ? "yes" : "no") unless options[:billable].nil?
query[:updated_since] = options[:updated_since].to_s if options[:updated_since]
response = request(:get, credentials, "/people/#{user.to_i}/entries", :query => query)
Harvest::TimeEntry.parse(JSON.parse(response.body).map {|h| h["day_entry"]})
end
|