Module: Toggl::Api::Task

Included in:
Base
Defined in:
lib/toggl_api/api/task.rb

Instance Method Summary collapse

Instance Method Details

#create_task(name, pid, options = {}) ⇒ Object

name: The name of the task (string, required, unique in project)

*pid*:              project ID for the task (integer, required)
 wid:               workspace ID, where the task will be saved (integer, project's workspace id is used when not supplied)
 uid:               user ID, to whom the task is assigned to (integer, not required)
 estimated_seconds: estimated duration of task in seconds (integer, not required)
 active:            whether the task is done or not (boolean, by default true)
 at:                timestamp that is sent in the response for PUT, indicates the time task was last updated


13
14
15
# File 'lib/toggl_api/api/task.rb', line 13

def create_task(name, pid, options={})
  post "/tasks", {"tag" => {"name" => name,"pid" =>pid}.merge(options)}
end

#delete_task(tid) ⇒ Object Also known as: bulk_delete_tasks



30
31
32
33
# File 'lib/toggl_api/api/task.rb', line 30

def delete_task(tid)
  tids = tids.join(',') if tids.is_a?(Array)
  delete "/tasks/#{tids}"
end

#get_task(tid) ⇒ Object Also known as: task



17
18
19
# File 'lib/toggl_api/api/task.rb', line 17

def get_task(tid)
  get "/tasks/#{tid}"
end

#update_task(tids, options) ⇒ Object Also known as: bulk_update_tasks



22
23
24
25
26
# File 'lib/toggl_api/api/task.rb', line 22

def update_task(tids, options)
  options = Hashie::Mash.new options
  tids = tids.join(',') if tids.is_a?(Array)
  put "/tasks/#{tids}",(options.key?(:task) ? options : {:task => options})
end