class Todoist::Sync::Projects

Public Instance Methods

add(args) click to toggle source

Add a project with a given hash of attributes and returns the project id

# File lib/todoist/sync/projects.rb, line 14
def add(args)
  return @client.api_helper.add(args, "project_add")
end
archive(projects) click to toggle source

Archive projects given an array of projects

# File lib/todoist/sync/projects.rb, line 26
def archive(projects)
  project_ids = projects.collect { |project| project.id }   
  args = {ids: project_ids.to_json}
  return @client.api_helper.command(args, "project_archive")
end
collection() click to toggle source

Return a Hash of projects where key is the id of a project and value is a project

# File lib/todoist/sync/projects.rb, line 9
def collection
  return @client.api_helper.collection("projects")
end
delete(projects) click to toggle source

Delete projects given an array of projects

# File lib/todoist/sync/projects.rb, line 19
def delete(projects)
  project_ids = projects.collect { |project| project.id }   
  args = {ids: project_ids.to_json}
  return @client.api_helper.command(args, "project_delete")
end
unarchive(projects) click to toggle source

Unarchive projects given an array of projects

# File lib/todoist/sync/projects.rb, line 33
def unarchive(projects)
  project_ids = projects.collect { |project| project.id }   
  args = {ids: project_ids.to_json}
  return @client.api_helper.command(args, "project_unarchive")
end
update(args) click to toggle source

Update project given a hash of attributes

# File lib/todoist/sync/projects.rb, line 40
def update(args)
  return @client.api_helper.command(args, "project_update")
end
update_multiple_orders_and_indents(projects) click to toggle source

Update orders and indents for an array of projects

# File lib/todoist/sync/projects.rb, line 45
def update_multiple_orders_and_indents(projects)
  tuples = {}
  projects.each do |project|
    tuples[project.id] = [project.item_order, project.indent]
  end
  args = {ids_to_orders_indents: tuples.to_json}
  return @client.api_helper.command(args, "project_update_orders_indents")
end