Class: TogglRb::Reports::Summary

Inherits:
Object
  • Object
show all
Includes:
EndpointDSL
Defined in:
lib/toggl_rb/reports/summary.rb

Instance Method Summary collapse

Methods included from EndpointDSL

#build_params, #build_query_params, included, #params_for_method, #query_params_for_method, #request_method, #request_path

Instance Method Details

#search_time_entries(workspace_id, params = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/toggl_rb/reports/summary.rb', line 35

def search_time_entries(workspace_id, params = {})
  params_object = build_params(params)
  params_object.validate_required!
  resource_path = format(request_path, workspace_id: workspace_id)
  response = send_request(request_method, resource_path, params_object)
  request_options = params.fetch(:request_options, {})
  get_all = request_options.fetch(:get_all, false)

  return response.body_json unless get_all

  all_tasks = response.body_json

  while response.more?
    params_object.first_row_number = response.next_row_number
    response = send_request(request_method, resource_path, params_object)
    all_tasks += response.body_json
  end

  all_tasks
end