Class: TogglBillable::Reports::Details
- Defined in:
- lib/toggl_billable/reports/details.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#billable_items, #initialize, #last_month_billable
Constructor Details
This class inherits a constructor from TogglBillable::Reports::Base
Instance Method Details
#get_report(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/toggl_billable/reports/details.rb', line 4 def get_report( = {}) params[:since] = [:start_date] params[:until] = [:end_date] params[:grouping] = [:grouping] if [:grouping] params[:subgrouping] = [:subgrouping] if [:grouping] params[:page] = [:page] || 1 params[:order_field] = [:oder_field] || 'date' count = 0 result = {} loop do request = "details?user_agent=reports&#{hash_to_params}" response = JSON.parse(Client.report_get(request).body) if result.size == 0 result = response else result['data'] += response['data'] end count += response['data'].count break if count >= response['total_count'] params[:page] += 1 end result end |