Class: Basecamp::Services::TodolistsService

Inherits:
BaseService
  • Object
show all
Defined in:
lib/basecamp/generated/services/todolists_service.rb

Overview

Service for Todolists operations

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from Basecamp::Services::BaseService

Instance Method Details

#create(todoset_id:, name:, description: nil, visible_to_clients: nil) ⇒ Hash

Create a new todolist in a todoset

Parameters:

  • todoset_id (Integer)

    todoset id ID

  • name (String)

    name

  • description (String, nil) (defaults to: nil)

    description

  • visible_to_clients (Boolean, nil) (defaults to: nil)

    visible to clients

Returns:

  • (Hash)

    response data



60
61
62
63
64
# File 'lib/basecamp/generated/services/todolists_service.rb', line 60

def create(todoset_id:, name:, description: nil, visible_to_clients: nil)
  with_operation(service: "todolists", operation: "create", is_mutation: true, resource_id: todoset_id) do
    http_post("/todosets/#{todoset_id}/todolists.json", body: compact_params(name: name, description: description, visible_to_clients: visible_to_clients)).json
  end
end

#get(id:) ⇒ Hash

Get a single todolist or todolist group by id

Parameters:

  • id (Integer)

    id ID

Returns:

  • (Hash)

    response data



13
14
15
16
17
# File 'lib/basecamp/generated/services/todolists_service.rb', line 13

def get(id:)
  with_operation(service: "todolists", operation: "get", is_mutation: false, resource_id: id) do
    http_get("/todolists/#{id}", operation: "GetTodolistOrGroup").json
  end
end

#list(todoset_id:, status: nil, page: nil, max_items: nil) ⇒ ListEnumerator<Hash>

List todolists in a todoset

Parameters:

  • todoset_id (Integer)

    todoset id ID

  • status (String, nil) (defaults to: nil)

    active|archived|trashed

  • page (Integer, nil) (defaults to: nil)

    Page number for paginating through results. Defaults to 1. A positive value selects exactly that page, not a starting offset; see SPEC section 8.

  • max_items (Integer, nil) (defaults to: nil)

    cap on items yielded across pages; nil or non-positive means no cap

Returns:

  • (ListEnumerator<Hash>)

    lazily paginated results (#meta carries pagination metadata)



47
48
49
50
51
52
# File 'lib/basecamp/generated/services/todolists_service.rb', line 47

def list(todoset_id:, status: nil, page: nil, max_items: nil)
  wrap_paginated(service: "todolists", operation: "list", is_mutation: false, resource_id: todoset_id) do
    params = compact_query_params(status: status, page: page)
    paginate("/todosets/#{todoset_id}/todolists.json", params: params, operation: "ListTodolists", max_items: max_items)
  end
end

#replace(id:, name:, description: nil) ⇒ Hash

Replace a todolist (or todolist group) with a new complete representation.

Parameters:

  • id (Integer)

    id ID

  • name (String)

    Name (required for a to-do list and for a group alike) - presence-validated server-side, so omitting it is a 422, not a preserve

  • description (String, nil) (defaults to: nil)

    Description (rich text HTML) - writable for a todolist group as well as a todolist, and omitting it clears it either way

Returns:

  • (Hash)

    response data



24
25
26
27
28
# File 'lib/basecamp/generated/services/todolists_service.rb', line 24

def replace(id:, name:, description: nil)
  with_operation(service: "todolists", operation: "replace", is_mutation: true, resource_id: id) do
    http_put("/todolists/#{id}", body: compact_params(name: name, description: description)).json
  end
end

#reposition(todolist_id:, position:) ⇒ void

This method returns an undefined value.

Reposition a to-do list within its to-do set.

Parameters:

  • todolist_id (Integer)

    todolist id ID

  • position (Integer)

    position



34
35
36
37
38
39
# File 'lib/basecamp/generated/services/todolists_service.rb', line 34

def reposition(todolist_id:, position:)
  with_operation(service: "todolists", operation: "reposition", is_mutation: true, resource_id: todolist_id) do
    http_put("/todosets/todolists/#{todolist_id}/position.json", body: compact_params(position: position))
    nil
  end
end