Class: Todoist::Sync::Projects
- Inherits:
-
Todoist::Service
- Object
- Todoist::Service
- Todoist::Sync::Projects
- Includes:
- Util
- Defined in:
- lib/todoist/sync/projects.rb
Instance Method Summary collapse
-
#add(args) ⇒ Object
Add a project with a given hash of attributes and returns the project id.
-
#archive(projects) ⇒ Object
Archive projects given an array of projects.
-
#collection ⇒ Object
Return a Hash of projects where key is the id of a project and value is a project.
-
#delete(projects) ⇒ Object
Delete projects given an array of projects.
-
#unarchive(projects) ⇒ Object
Unarchive projects given an array of projects.
-
#update(args) ⇒ Object
Update project given a hash of attributes.
-
#update_multiple_orders_and_indents(projects) ⇒ Object
Update orders and indents for an array of projects.
Methods inherited from Todoist::Service
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
26 27 28 29 30 |
# 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 ⇒ Object
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(projects) ⇒ Object
Delete projects given an array of projects
19 20 21 22 23 |
# 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) ⇒ Object
Unarchive projects given an array of projects
33 34 35 36 37 |
# 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) ⇒ Object
Update project given a hash of attributes
40 41 42 |
# 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) ⇒ Object
Update orders and indents for an array of projects
45 46 47 48 49 50 51 52 |
# 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 |