Module: Tacokit::Client::Lists

Included in:
Tacokit::Client
Defined in:
lib/tacokit/client/lists.rb

Overview

Methods for the Lists API

Instance Method Summary collapse

Instance Method Details

#archive_list_cards(list_id) ⇒ Object

Archive all cards in a list

Examples:

Archive cards

list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
Tacokit.archive_all_cards(list)

Parameters:

  • list_id (String, Tacokit::Resource<Card>)

    the list identifier, shortlink, or list

See Also:



88
89
90
# File 'lib/tacokit/client/lists.rb', line 88

def archive_list_cards(list_id)
  post list_path(list_id, camp("archive_all_cards"))
end

#create_list(board_id, name, options = {}) ⇒ Tacokit::Resource<List>

Create a new list

Examples:

Create a new list on the top

board = Tacokit.board("aBoardId")
Tacokit.create_list(board, "New List", pos: "top")  #=> Tacokit::Resource<List>

Parameters:

  • board_id (String)

    the board identifier

  • name (String)

    a name for the list

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

    options to create the list with

Returns:

See Also:



78
79
80
# File 'lib/tacokit/client/lists.rb', line 78

def create_list(board_id, name, options = {})
  post "lists", options.merge(name: name, board_id: resource_id(board_id))
end

#list(list_id, options = nil) ⇒ Tacokit::Resource<List>

Retrieve a list by id

Examples:

Retrieve a list by its id with its open cards

Tacokit.list("aListId", cards: "open") #=> Tacokit::Resource<List>

Parameters:

  • list_id (String)

    the list identifier or shortlink

Returns:

See Also:



12
13
14
# File 'lib/tacokit/client/lists.rb', line 12

def list(list_id, options = nil)
  get list_path(list_id), options
end

#list_actions(list_id, options = {}) ⇒ Tacokit::Collection<Action>

Retrieve list’s actions

Examples:

fetch “comment” actions for a given list

list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
Tacokit.list_actions(list, filter: "comment_card") #=> Tacokit::Collection<Action>

Parameters:

  • list_id (String, Tacokit::Resource<List>)

    the list identifier, shortlink, or list

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

    the options to fetch the actions with

Returns:

See Also:



24
25
26
# File 'lib/tacokit/client/lists.rb', line 24

def list_actions(list_id, options = {})
  paginated_list_resource list_id, "actions", options
end

#list_board(list_id, options = {}) ⇒ Tacokit::Resource<Board>

Retrieve a list’s board

Examples:

fetch a list’s board

list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
Tacokit.list_board(list) #=> Tacokit::Resource<Board>

Parameters:

  • list_id (String, Tacokit::Resource<List>)

    the list identifier, shortlink, or list

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

    the options to fetch the board with

Returns:

See Also:



36
37
38
# File 'lib/tacokit/client/lists.rb', line 36

def list_board(list_id, options = {})
  list_resource list_id, "board", options
end

#list_cards(list_id, options = {}) ⇒ Tacokit::Collection<Card>

Retrive a list’s cards

Examples:

fetch list cards

list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
Tacokit.list_cards(list) #=> Tacokit::Collection<Card>

fetch list cards with attachments, members, stickers

Tacokit.list_cards(list, attachments: true, members: true, stickers: true) #=> Tacokit::Collection<Card>

configure a local client, fetch a list“s cards with a subset of attributes

client = Tacokit::Client.new app_key: "another-app-key"
client.list_cards(list) #=> Tacokit::Collection<Card>

Parameters:

  • list_id (String, Tacokit::Resource<List>)

    the list identifier or list

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

    the options to fetch the cards with

Returns:

See Also:



53
54
55
# File 'lib/tacokit/client/lists.rb', line 53

def list_cards(list_id, options = {})
  paginated_list_resource list_id, "cards", options
end

#move_list_cards(list_id, destination_list_id, board_id = nil) ⇒ Object

Move cards from one list to another

Examples:

Move cards from list A to B

listA = Tacokit.list("aListId") #=> Tacokit::Resource<List>
listB = Tacokit.list("bListId") #=> Tacokit::Resource<List>
Tacokit.move_all_cards(listA, listB)

Parameters:

  • list_id (String, Tacokit::Resource<List>)

    the source list identifier or list

  • destination_list_id (String, Tacokit::Resource<List>)

    the destination list identifier

  • board_id (String) (defaults to: nil)

    the board identifier

See Also:



101
102
103
104
105
# File 'lib/tacokit/client/lists.rb', line 101

def move_list_cards(list_id, destination_list_id, board_id = nil)
  board_id ||= resolve_board_id(destination_list_id)
  post list_path(list_id, camp("move_all_cards")),
    list_id: resource_id(destination_list_id), board_id: resource_id(board_id)
end

#update_list(list_id, options = {}) ⇒ Tacokit::Resource<List>

Update a list’s attributes

Examples:

Change a list’s name and position

list = Tacokit.list("aListId") #=> Tacokit::Resource<List>
Tacokit.update_list(list, name: "New Name", pos: "top") #=> Tacokit::Resource<List>

Parameters:

  • list_id (String, Tacokit::Resource<List>)

    the list identifier, shortlink, or list

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

    the attributes to update on the list

Returns:

See Also:



65
66
67
# File 'lib/tacokit/client/lists.rb', line 65

def update_list(list_id, options = {})
  put list_path(list_id), options
end