Module: Camper::Client::TodolistsAPI

Included in:
Camper::Client
Defined in:
lib/camper/api/todolists.rb

Overview

Defines methods related to todolists.

Instance Method Summary collapse

Instance Method Details

#create_todolist(todoset, name, description = '') ⇒ Resource

Create a todolist within the given todoset

Examples:

client.create_todolist(todoset, 'Launch', "<div><em>Finish it!</em></div>")

Parameters:

  • todoset (Resource)

    the parent todoset resource

  • name (String)

    the name of the new todolist

  • description (String) (defaults to: '')

    an optional description for the todolist

Returns:

Raises:

See Also:



50
51
52
53
54
# File 'lib/camper/api/todolists.rb', line 50

def create_todolist(todoset, name, description = '')
  body = { name: name, description: description }

  post(todoset.todolists_url, body: body, override_path: true)
end

#todolist(todoset, id) ⇒ Resource

Get a todolist with a given id

Examples:

client.todolist(todoset, '2345')

Parameters:

  • todoset (Resource)

    the parent todoset resource

  • id (Integer, String)

    the id of the todolist to get

Returns:

See Also:



34
35
36
# File 'lib/camper/api/todolists.rb', line 34

def todolist(todoset, id)
  get("/buckets/#{todoset.bucket.id}/todolists/#{id}")
end

#todolists(todoset, options = {}) ⇒ PaginatedResponse<Resource>

Get the todolists associated with the todoset

Examples:

client.todolists(todoset)
client.todolists(todoset, status: 'archived')

Parameters:

  • todoset (Resource)

    the parent todoset resource

  • options (Hash) (defaults to: {})

    extra options to filter the list of todolist

Returns:

Raises:

See Also:



21
22
23
# File 'lib/camper/api/todolists.rb', line 21

def todolists(todoset, options = {})
  get(todoset.todolists_url, query: options, override_path: true)
end

#trash_todolist(todolist) ⇒ Object

Trash a todolist

it calls the trash_recording endpoint under the hood

Examples:

client.trash_todolist(todolist)

Parameters:

  • todolist (Resource)

    the todolist to be trashed

Raises:

See Also:



90
91
92
# File 'lib/camper/api/todolists.rb', line 90

def trash_todolist(todolist)
  trash_recording(todolist)
end

#update_todolist(todolist, name, description = nil) ⇒ Resource

Update a todolist to change name and description

Examples:

client.update_todolist(todolist, 'Launch')
client.update_todolist(todolist, 'Launch', "<div><em>Finish it!</em></div>")
client.update_todolist(todolist, 'Launch', '')

Parameters:

  • todolist (Resource)

    the todolist resource to update

  • name (String)

    the new name of the todolist

  • description (String) (defaults to: nil)

    a new optional description for the todolist. If not specified, it will be set to the current description value

Returns:

Raises:

See Also:



73
74
75
76
77
78
# File 'lib/camper/api/todolists.rb', line 73

def update_todolist(todolist, name, description = nil)
  body = { name: name }
  body[:description] = description.nil? ? todolist.description : description

  put(todolist.url, body: body, override_path: true)
end