class Nin::Integration::Service::Todoist::Project

Public Instance Methods

add(project) click to toggle source
# File lib/nin/integration/service/todoist.rb, line 21
def add(project)
  commands = [
    {
      "type": "project_add",
      "temp_id": SecureRandom.uuid,
      "uuid": SecureRandom.uuid,
      "args": project
    }
  ].to_json

  @client.sync.write_resources(commands).fetch('temp_id_mapping').values.first
end
all() click to toggle source
# File lib/nin/integration/service/todoist.rb, line 14
def all
  @client
    .sync
    .read_resources(['projects'])
    .fetch('projects').reduce({}) { |projects, p| projects.update(p["id"] => p["name"]) }
end