Module: Tacokit::Client::Cards

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

Overview

Methods for the Cards API

See Also:

Instance Method Summary (collapse)

Instance Method Details

- (Object) add_checklist(card_id, name) Also known as: start_checklist

Start a new checklist on card

Examples:

Add checklist to card

card = Tacokit.card("aCardId")
checklist = Tacokit.add_checklist(card, "Tasks")

Parameters:

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

    the card identifier, shortlink, or card

  • name (String)

    the new checklist name

See Also:


327
328
329
# File 'lib/tacokit/client/cards.rb', line 327

def add_checklist(card_id, name)
  create_card_resource(card_id, "checklists", name: name)
end

- (Object) add_comment(card_id, text, options = {}) Also known as: create_card_comment

Add a comment to a card

Examples:

Add comment to a card

Tacokit.add_comment("aCardId", "@bob What do you mean?")

Parameters:

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

    the card identifier, shortlink, or card

  • text (String)

    comment text

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

    options to create the comment with

See Also:


273
274
275
276
# File 'lib/tacokit/client/cards.rb', line 273

def add_comment(card_id, text, options = {})
  options.update text: text
  create_card_resource card_id, "actions", "comments", options
end

- (Object) add_label(card_id, color, options = {})

Add label to card

Examples:

Add label to card

Tacokit.add_label("aCardId", "red", name: "Overdue")

Parameters:

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

    the card identifier, shortlink, or card

  • color (String)

    a color name or hex value

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

    options to add the label with

See Also:


365
366
367
# File 'lib/tacokit/client/cards.rb', line 365

def add_label(card_id, color, options = {})
  create_card_resource(card_id, "labels", options.merge(color: color))
end

- (Object) add_member_to_card(card_id, member_id)

Add a member to a card

Examples:

Add a member to a card

card = Tacokit.card("aCardId")
member = Tacokit.member("nickname")
Tacokit.add_member_to_card(card, member)

Add a member by id to a card

Tacokit.add_member_to_card("aCardId", "aMemberId")

Parameters:

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

    the card identifier, shortlink, or card

  • member_id (String)

    the member identifier

See Also:


354
355
356
# File 'lib/tacokit/client/cards.rb', line 354

def add_member_to_card(card_id, member_id)
  create_card_resource(card_id, "idMembers", value: resource_id(member_id))
end

- (Object) add_sticker(card_id, image_name, options = {}) Also known as: create_sticker

Add sticker to card

Examples:

Add sticker to card with optional positioning

Tacokit.add_sticker("aCardId", "star", top: 100, left: 200, z_index: 50)

Parameters:

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

    the card identifier, shortlink, or card

  • image_name (String)

    the sticker name

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

    options to add the sticker with, such as position arguments

See Also:


388
389
390
391
# File 'lib/tacokit/client/cards.rb', line 388

def add_sticker(card_id, image_name, options = {})
  defaults = { top: 0, left: 0, z_index: 1 }
  create_card_resource(card_id, "stickers", defaults.merge(options.merge(image: image_name)))
end

- (Object) archive_card(card_id)

Archive a card

Examples:

Archive a card

Tacokit.archive_card("aCardId")

Parameters:

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

    the card identifier, shortlink, or card

See Also:


187
188
189
# File 'lib/tacokit/client/cards.rb', line 187

def archive_card(card_id)
  update_card(card_id, closed: true)
end

- (Object) attach_file(card_id, url, mime_type = nil, options = {}) Also known as: create_card_attachment

Attach a file to a card

Examples:

Attach a file from the file system

Tacokit.attach_file("aCardId", "/path/to/local/file.png")

Attach a file the “Internet” with mime type

Tacokit.attach_file("aCardId", "https://imgur.com/giphy.gif", "image/gif")

Parameters:

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

    the card identifier, shortlink, or card

  • url (String)

    a local file path of http url to a file

  • mime_type (String) (defaults to: nil)

    a mime type for http url

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

    additional options to attach the file with

See Also:


289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/tacokit/client/cards.rb', line 289

def attach_file(card_id, url, mime_type = nil, options = {})
  options = mime_type if mime_type.is_a?(Hash)

  uri = URI.parse(url)

  if uri.scheme =~ %r{https?}
    options.update url: uri.to_s, mime_type: mime_type
  else
    file = Faraday::UploadIO.new(uri.to_s, mime_type)
    options.update file: file, mime_type: file.content_type
  end

  create_card_resource card_id, "attachments", options
end

- (Tacokit::Resource<Attachment>) attachment(card_id, attachment_id, options = {})

Retrieve a card attachment

Examples:

Retrieve a single card attachment

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.attachment(card, "anAttachmentId") #=> Tacokit::Resource<Attachment>

Parameters:

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

    the card identifier, shortlink, or card

  • attachment_id (String)

    the attachment id

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

    the options to fetch the attachments with

Returns:

See Also:


54
55
56
# File 'lib/tacokit/client/cards.rb', line 54

def attachment(card_id, attachment_id, options = {})
  card_resource(card_id, "attachments/#{resource_id(attachment_id)}", options)
end

- (Tacokit::Collection<Attachment>) attachments(card_id, options = {}) Also known as: card_attachments

Retrieve card attachments

Examples:

Retrieve attachments for a card

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.attachments(card) #=> Tacokit::Collection<Attachment>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the attachments with

Returns:

See Also:


40
41
42
# File 'lib/tacokit/client/cards.rb', line 40

def attachments(card_id, options = {})
  card_resource(card_id, "attachments", options)
end

- (Tacokit::Resource<Card>) card(card_id, options = nil)

Retrieve a card by id or shortlink

Examples:

Retrieve a card by its id

Tacokit.card("aCardId") #=> Tacokit::Resource<Card>

Retrieve a card by its short link with its members

Tacokit.card("aCardShortLink", members: true) #=> Tacokit::Resource<Card>

Parameters:

  • card_id (String)

    the card identifier or shortlink

Returns:

See Also:


16
17
18
# File 'lib/tacokit/client/cards.rb', line 16

def card(card_id, options = nil)
  get card_path(card_id), options
end

- (Tacokit::Collection<Action>) card_actions(card_id, options = {})

Retrieve card actions

Examples:

Retrieve a card's comments

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.card_actions(card, filter: "comment_card") #=> Tacokit::Collection<Action>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the actions with

Returns:

See Also:


28
29
30
# File 'lib/tacokit/client/cards.rb', line 28

def card_actions(card_id, options = {})
  paginated_card_resource(card_id, "actions", options)
end

- (Tacokit::Resource<Board>) card_board(card_id, options = {})

Retrieve a card board

Examples:

Retrieve a card board

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.card_board(card) #=> Tacokit::Resource<Board>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the board with

Returns:

See Also:


66
67
68
# File 'lib/tacokit/client/cards.rb', line 66

def card_board(card_id, options = {})
  card_resource(card_id, "board", options)
end

- (Tacokit::Resource<List>) card_list(card_id, options = {})

Retrive a card list

Examples:

Retrieve a card list

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.card_list(card) #=> Tacokit::Resource<List>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the list with

Returns:

See Also:


101
102
103
# File 'lib/tacokit/client/cards.rb', line 101

def card_list(card_id, options = {})
  card_resource(card_id, "list", options)
end

- (Tacokit::Collection) card_members(card_id, options = {})

Retrieve card members

Examples:

Retrieve a card's members

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.card_members(card) #=> Tacokit::Collection<Member>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the members with

Returns:

See Also:


113
114
115
# File 'lib/tacokit/client/cards.rb', line 113

def card_members(card_id, options = {})
  card_resource(card_id, "members", options)
end

- (Tacokit::Collection) card_members_voted(card_id, options = {})

Retrieve members who voted on a card

Examples:

Retrieve members who voted for card

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.card_members_voted(card) #=> Tacokit::Collection<Member>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the members with

Returns:

See Also:


125
126
127
# File 'lib/tacokit/client/cards.rb', line 125

def card_members_voted(card_id, options = {})
  card_resource(card_id, "members_voted", options)
end

- (Tacokit::Collection) check_item_states(card_id, options = {})

Retrieve card checklist item states

Examples:

Retrieve states of checked items

Tacokit.check_item_states("aCardId") #=> Tacokit::Collection

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the states with

Returns:

See Also:


77
78
79
# File 'lib/tacokit/client/cards.rb', line 77

def check_item_states(card_id, options = {})
  card_resource(card_id, "check_item_states", options)
end

- (Tacokit::Collection<Checklist>) checklists(card_id, options = {})

Retrieve card checklists

Examples:

Retrieve checklists

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.checklists(card) #=> Tacokit::Collection<Checklist>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the checklists with

Returns:

See Also:


89
90
91
# File 'lib/tacokit/client/cards.rb', line 89

def checklists(card_id, options = {})
  card_resource(card_id, "checklists", options)
end

- (Object) convert_to_card(card_id, checklist_id, check_item_id)

Convert a checklist item to a card

Examples:

Convert a checklist item to a card

card = Tacokit.card("aCardId", checklists: :all)
checklist = card.checklists.first
check_item = checklist.check_items.first
Tacokit.convert_to_card(card, checklist, check_item)

Parameters:

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

    the card identifier, shortlink, or card

  • checklist_id (String)

    the checklist identifier

  • check_item_id (String)

    the check item identifier to convert to a card

See Also:


315
316
317
318
# File 'lib/tacokit/client/cards.rb', line 315

def convert_to_card(card_id, checklist_id, check_item_id)
  create_card_resource card_id, "checklist", resource_id(checklist_id),
    "checkItem", resource_id(check_item_id), "convertToCard"
end

- (Object) copy_checklist(card_id, checklist_id)

Copy another checklist to card

Parameters:

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

    the destination card identifier, shortlink, or card

  • checklist_id (String)

    the checklist identifier card_1 = Tacokit.card(“aCardId”) checklist = card.add_checklist(card_1, “Tasks”) card_2 = Tacokit.card(“bCardId”) Tacokit.copy_checklist(card_2, checklist)

See Also:


340
341
342
# File 'lib/tacokit/client/cards.rb', line 340

def copy_checklist(card_id, checklist_id)
  create_card_resource(card_id, "checklists", checklist_source_id: resource_id(checklist_id))
end

- (Object) create_card(list_id, name = nil, options = {})

Create a new card

Examples:

Create a new card at bottom of a given list

Tacokit.create_card("aListId", "Card name", pos: "bottom")

Parameters:

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

    the list identifier or list

  • name (String) (defaults to: nil)

    a name for the card

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

    options to create the card with

See Also:


262
263
264
# File 'lib/tacokit/client/cards.rb', line 262

def create_card(list_id, name = nil, options = {})
  post "cards", options.merge(name: name, list_id: resource_id(list_id))
end

- (Object) create_card_resource(card_id, resource, *paths)

Create a card resource


396
397
398
399
# File 'lib/tacokit/client/cards.rb', line 396

def create_card_resource(card_id, resource, *paths)
  paths, options = extract_options(camp(resource), *paths)
  post card_path(card_id, *paths), options
end

- (Object) delete_card(card_id)

Delete a card

Examples:

Delete a card

card = Tacokit.card("aCardId")
Tacokit.delete_card(card)

Parameters:

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

    the card identifier, shortlink, or card

See Also:


407
408
409
# File 'lib/tacokit/client/cards.rb', line 407

def delete_card(card_id)
  delete card_path(resource_id(card_id))
end

- (Object) move_card(card_id, options)

Move card to another position, board and/or list

Examples:

Move card to the top of a new list

card = Tacokit.card("aCardId")
Tacokit.move_card(card, list_id: "aListId", pos: "top")

Parameters:

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

    the card identifier, shortlink, or card

  • options (Hash)

    the options for moving the card

Options Hash (options):

  • :board_id (String)

    another board location

  • :list_id (String)

    another list location

  • :pos (String)

    new position in current list

See Also:


211
212
213
214
215
216
# File 'lib/tacokit/client/cards.rb', line 211

def move_card(card_id, options)
  unless options.is_a?(Hash) && ([:board_id, :list_id, :pos].any? { |key| options.key? key })
    raise ArgumentError, "Required option: :pos, :board_id and/or :list_id"
  end
  update_card(card_id, options)
end

- (Object) remove_attachment(card_id, attachment_id) Also known as: delete_attachement

Remove an attachment

Examples:

Remove an attachment

card = Tacokit.card("aCardId")
attachment = Tacokit.attach_file(card, "/path/to/local/file.png")
Tacokit.remove_attachment(card, attachment)

Parameters:

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

    the card identifier, shortlink, or card

  • attachment_id (String)

    the attachment identifier

See Also:


432
433
434
# File 'lib/tacokit/client/cards.rb', line 432

def remove_attachment(card_id, attachment_id)
  delete_card_resource card_id, "attachments", resource_id(attachment_id)
end

- (Object) remove_card_member(card_id, member_id) Also known as: delete_card_member

Remove a member from a card

Examples:

Remove a member from a card

card = Tacokit.card("aCardId")
member = Tacokit.member("nickname")
Tacokit.remove_card_member(card, member)

Remove member by id from a card

Tacokit.remove_card_member("aCardId", "aMemberId")

Parameters:

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

    the card identifier, shortlink, or card

  • member_id (String)

    the member identifier

See Also:


459
460
461
# File 'lib/tacokit/client/cards.rb', line 459

def remove_card_member(card_id, member_id)
  delete_card_resource card_id, "idMembers", resource_id(member_id)
end

- (Object) remove_checklist(card_id, checklist_id) Also known as: delete_checklist

Remove checklist

Parameters:

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

    the card identifier, shortlink, or card

  • checklist_id (String)

    the checklist identifier card = Tacokit.card(“aCardId”) checklist = Tacokit.create_checklist(card, “Things”) Tacokit.remove_checklist(card, checklist)

See Also:


444
445
446
# File 'lib/tacokit/client/cards.rb', line 444

def remove_checklist(card_id, checklist_id)
  delete_card_resource card_id, "checklists", checklist_id
end

- (Object) remove_comment(card_id, comment_id) Also known as: delete_comment

Remove a comment

Examples:

Remove a comment

card = Tacokit.card("aCardId")
comment = Tacokit.add_comment(card, "This message will be deleted")
Tacokit.remove_comment(comment)

Parameters:

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

    the card identifier, shortlink, or card

  • comment_id (String)

    the comment identifier

See Also:


419
420
421
# File 'lib/tacokit/client/cards.rb', line 419

def remove_comment(card_id, comment_id)
  delete_card_resource card_id, "actions", resource_id(comment_id), "comments"
end

- (Object) remove_label(card_id, color) Also known as: delete_label

Remove label from card

Examples:

Remove label from card

Tacokit.remove_label("aCardId", "red", name: "Overdue")

Parameters:

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

    the card identifier, shortlink, or card

  • color (String)

    color of label to remove

See Also:


470
471
472
# File 'lib/tacokit/client/cards.rb', line 470

def remove_label(card_id, color)
  delete_card_resource card_id, "labels", color
end

- (Object) remove_sticker(card_id, sticker_id) Also known as: delete_sticker

Remove a sticker from a card

Examples:

Remove sticker from card with optional positioning

sticker = Tacokit.add_sticker("aCardId", "star")
Tacokit.remove_sticker("aCardId", sticker)

Parameters:

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

    the card identifier, shortlink, or card

  • sticker_id (String)

    the sticker identifier

See Also:


494
495
496
# File 'lib/tacokit/client/cards.rb', line 494

def remove_sticker(card_id, sticker_id)
  delete_card_resource card_id, "stickers", resource_id(sticker_id)
end

- (Object) remove_vote(card_id, member_id) Also known as: delete_vote

Remove a vote from a card

Examples:

Remove member's vote from a card

member = Tacokit.member("rossta")
Tacokit.remove_vote("aCardId", member)

Parameters:

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

    the card identifier, shortlink, or card

  • member_id (String)

    the member identifier

See Also:


482
483
484
# File 'lib/tacokit/client/cards.rb', line 482

def remove_vote(card_id, member_id)
  delete_card_resource card_id, "membersVoted", resource_id(member_id)
end

- (Object) restore_card(card_id)

Restore an archived card

Examples:

Restore a card

Tacokit.restore_card("aCardId")

Parameters:

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

    the card identifier, shortlink, or card

See Also:


196
197
198
# File 'lib/tacokit/client/cards.rb', line 196

def restore_card(card_id)
  update_card(card_id, closed: false)
end

- (Tacokit::Collection) stickers(card_id, options = {})

Retrieve card stickers

Examples:

Retrieve stickers on card

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.stickers(card) #=> Tacokit::Collection<Stickers>

Parameters:

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

    the card identifier, shortlink, or card

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

    the options to fetch the stickers with

Returns:

See Also:


137
138
139
# File 'lib/tacokit/client/cards.rb', line 137

def stickers(card_id, options = {})
  card_resource(card_id, "stickers", options)
end

- (Object) subscribe_to_card(card_id)

Subscribe to card

Examples:

Subscribe to card

Tacokit.subscribe_to_card("aCardId")

Parameters:

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

    the card identifier, shortlink, or card

See Also:


233
234
235
# File 'lib/tacokit/client/cards.rb', line 233

def subscribe_to_card(card_id)
  put card_path(card_id, "subscribed"), value: true
end

- (Object) unsubscribe_from_card(card_id)

Unubscribe from card

Examples:

Unubscribe from card

Tacokit.unsubscribe_from_card("aCardId")

Parameters:

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

    the card identifier, shortlink, or card

See Also:


242
243
244
# File 'lib/tacokit/client/cards.rb', line 242

def unsubscribe_from_card(card_id)
  put card_path(card_id, "subscribed"), value: false
end

- (Object) update_card(card_id, options = {})

Update card attributes

Examples:

Update name of card

card = Tacokit.card("aCardId") #=> Tacokit::Resource<Card>
Tacokit.update_card(card, name: "New card") #=> Tacokit::Resource<Card>

Parameters:

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

    the card identifier, shortlink, or card

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

    the attributes to update on the card

See Also:


148
149
150
# File 'lib/tacokit/client/cards.rb', line 148

def update_card(card_id, options = {})
  put card_path(card_id), options
end

- (Object) update_card_name(card_id, name)

Update card name

Examples:

Change card name

Tacokit.update_card_name("aCardId", "New card name")

Parameters:

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

    the card identifier, shortlink, or card

  • name (String)

    a name for the card

See Also:


224
225
226
# File 'lib/tacokit/client/cards.rb', line 224

def update_card_name(card_id, name)
  put card_path(card_id, "name"), value: name
end

- (Object) update_card_resource(card_id, resource, *paths)

Update any card resource

Parameters:

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

    the card identifier, shortlink, or card

  • resource (String)

    a resource name, like board, list, attachment

  • paths (Hash, String)

    nested paths and/or options for updating the card's nested resource


250
251
252
253
# File 'lib/tacokit/client/cards.rb', line 250

def update_card_resource(card_id, resource, *paths)
  paths, options = extract_options(camp(resource), *paths)
  put card_path(card_id, *paths), options
end

- (Object) update_check_item(card_id, checklist_id, check_item_id, options = {})

Update checklist item text, position or state

Parameters:

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

    the card identifier, shortlink, or card

  • checklist_id (String)

    the checklist identifier

  • check_item_id (String)

    the check item identifier

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

    the attributes to update on the check item

See Also:


173
174
175
176
177
178
179
180
# File 'lib/tacokit/client/cards.rb', line 173

def update_check_item(card_id, checklist_id, check_item_id, options = {})
  update_card_resource card_id,
    "checklist",
    resource_id(checklist_id),
    "checkItem",
    resource_id(check_item_id),
    options
end

- (Object) update_comment(card_id, comment_id, text, options = {}) Also known as: edit_comment

Update comment text

Examples:

Change text of existing comment

card = Tacokit.card("aCardId", action: "commentCard")
comment = card.actions.first
Tacokit.update_comment(card, comment, "New comment text")

Parameters:

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

    the card identifier, shortlink, or card

  • comment_id (String)

    the comment identifier

  • text (String)

    the updated comment text

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

    the attributes to update on the comment

See Also:


162
163
164
# File 'lib/tacokit/client/cards.rb', line 162

def update_comment(card_id, comment_id, text, options = {})
  update_card_resource(card_id, "actions", resource_id(comment_id), "comments", options.merge(text: text))
end

- (Object) vote(card_id, member_id) Also known as: create_vote

Cast vote for card

Examples:

Vote on card for given member

member = Tacokit.member("rossta")
Tacokit.vote("aCardId", member)

Parameters:

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

    the card identifier, shortlink, or card

  • member_id (String)

    the voter member identifier

See Also:


376
377
378
# File 'lib/tacokit/client/cards.rb', line 376

def vote(card_id, member_id)
  create_card_resource(card_id, "membersVoted", value: resource_id(member_id))
end