class TodoistClient::Project

Constants

VALID_PARAMS

Public Class Methods

all() click to toggle source
# File lib/todoist_client/project.rb, line 93
def all
  request(*Paths::ALL).map {|project| self.new(project)}
end
create(params) click to toggle source
# File lib/todoist_client/project.rb, line 101
def create(params)
  self.new(params).save
end
find(id) click to toggle source
# File lib/todoist_client/project.rb, line 97
def find(id)
  self.new(request(*Paths::FIND, {project_id: id}))
end
new(params = nil) click to toggle source
# File lib/todoist_client/project.rb, line 29
def initialize(params = nil)
  case
  when params.is_a?(String)
    @name = params
  when params.is_a?(Hash)
    set_params(params)
  end
end

Public Instance Methods

archive() click to toggle source

only premium user

# File lib/todoist_client/project.rb, line 66
def archive
  with_remote_object do
    self.class.request *Paths::ARCHIVE, {project_id: id}
  end
end
completed_items() click to toggle source

only premium user

# File lib/todoist_client/project.rb, line 86
def completed_items
  with_remote_object do
    Item.completed_items(id)
  end
end
delete() click to toggle source
# File lib/todoist_client/project.rb, line 59
def delete
  with_remote_object do
    self.class.request *Paths::DELETE, {project_id: id}
  end
end
save() click to toggle source
# File lib/todoist_client/project.rb, line 38
def save
  if id
    json = self.class.request *Paths::UPDATE, {
      project_id: @id, # required
      name: @name,
      color: @color,
      indent: @indent,
      order: @item_order
    }.select {|k,v| !v.nil?}
  else
    json = self.class.request *Paths::ADD, {
      name: @name, # required
      color: @color,
      indent: @indent,
      order: @item_order
    }.select {|k,v| !v.nil?}
  end
  set_params(json)
  self
end
unarchive() click to toggle source

only premium user

# File lib/todoist_client/project.rb, line 73
def unarchive
  with_remote_object do
    self.class.request *Paths::UNARCHIVE, {project_id: id}
  end
end
uncompleted_items() click to toggle source
# File lib/todoist_client/project.rb, line 79
def uncompleted_items
  with_remote_object do
    Item.uncompleted(id)
  end
end