Class: Todoist::Sync::Projects

Inherits:
Todoist::Service show all
Includes:
Util
Defined in:
lib/todoist/sync/projects.rb

Instance Method Summary collapse

Methods inherited from Todoist::Service

#initialize

Constructor Details

This class inherits a constructor from Todoist::Service

Instance Method Details

#add(args) ⇒ Object

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



14
15
16
# File 'lib/todoist/sync/projects.rb', line 14

def add(args)
  return @client.api_helper.add(args, "project_add")
end

#archive(projects) ⇒ Object

Archive projects given an array of projects



25
26
27
28
29
# File 'lib/todoist/sync/projects.rb', line 25

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

#collectionObject

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



9
10
11
# File 'lib/todoist/sync/projects.rb', line 9

def collection
  return @client.api_helper.collection("projects")
end

#delete(project_id) ⇒ Object

Delete a project given a project id



19
20
21
22
# File 'lib/todoist/sync/projects.rb', line 19

def delete(project_id)
  args = {id: project_id}
  return @client.api_helper.command(args, "project_delete")
end

#unarchive(projects) ⇒ Object

Unarchive projects given an array of projects



32
33
34
35
36
# File 'lib/todoist/sync/projects.rb', line 32

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) ⇒ Object

Update project given a hash of attributes



39
40
41
# File 'lib/todoist/sync/projects.rb', line 39

def update(args)
  return @client.api_helper.command(args, "project_update")
end

#update_multiple_orders_and_indents(projects) ⇒ Object

Update orders and indents for an array of projects



44
45
46
47
48
49
50
51
# File 'lib/todoist/sync/projects.rb', line 44

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