Class: TogglRb::Reports::Detailed

Inherits:
Object
  • Object
show all
Includes:
EndpointDSL
Defined in:
lib/toggl_rb/reports/detailed.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



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/toggl_rb/reports/detailed.rb', line 48

def search_time_entries(workspace_id, params = {})
  request_options = params.delete(:request_options) || {}
  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)
  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