Class: Todoist::Misc::Completed

Inherits:
Service
  • Object
show all
Includes:
Util
Defined in:
lib/todoist/misc/completed.rb

Instance Method Summary collapse

Methods inherited from Service

#initialize

Constructor Details

This class inherits a constructor from Todoist::Service

Instance Method Details

#get_all_completed_items(params = {}) ⇒ Object

Retrieves all completed items as documented at developer.todoist.com/#get-all-completed-items. Several parameters are possible to limit scope. See link. Dates should be passed as DateTime. This method takes care of the formatting to send to the API. Returns projects and items back as :items and :projects keys.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/todoist/misc/completed.rb', line 18

def get_all_completed_items(params = {})
  if params["until"]
    params["until"] = ParseHelper.format_time(params["until"])
  end
  if params["since"]
    params["since"] = ParseHelper.format_time(params["since"])
  end
  
  result = @client.api_helper.get_response(Config::TODOIST_COMPLETED_GET_ALL_COMMAND, params)
  items = ParseHelper.make_objects_as_array(result["items"])
  projects = ParseHelper.make_objects_as_array(result["projects"])
  return {"items" => items, "projects" => projects}
end

#get_productivity_statsObject

Get productivity stats. Returns a hash of statistics as documented at developer.todoist.com/#get-productivity-stats



8
9
10
# File 'lib/todoist/misc/completed.rb', line 8

def get_productivity_stats()
  @client.api_helper.get_response(Config::TODOIST_COMPLETED_GET_STATS_COMMAND, {})
end