Module: Tacokit::Client::Cards
- Included in:
- Tacokit::Client
- Defined in:
- lib/tacokit/client/cards.rb
Overview
Methods for the Cards API
Instance Method Summary collapse
-
#add_checklist(card_id, name) ⇒ Object
(also: #start_checklist)
Start a new checklist on card.
-
#add_comment(card_id, text, options = {}) ⇒ Object
(also: #create_card_comment)
Add a comment to a card.
-
#add_label(card_id, color, options = {}) ⇒ Object
Add label to card.
-
#add_member_to_card(card_id, member_id) ⇒ Object
Add a member to a card.
-
#add_sticker(card_id, image_name, options = {}) ⇒ Object
(also: #create_sticker)
Add sticker to card.
-
#archive_card(card_id) ⇒ Object
Archive a card.
-
#attach_file(card_id, url, mime_type = nil, options = {}) ⇒ Object
(also: #create_card_attachment)
Attach a file to a card.
-
#attachment(card_id, attachment_id, options = {}) ⇒ Object
Retrieve a card attachment.
-
#attachments(card_id, options = {}) ⇒ Object
(also: #card_attachments)
Retrieve card attachments.
-
#card(card_id, options = nil) ⇒ Object
Retrieve a card by id or shortlink.
-
#card_actions(card_id, options = {}) ⇒ Object
Retrieve card actions.
-
#card_board(card_id, options = {}) ⇒ Object
Retrieve a card board.
-
#card_list(card_id, options = {}) ⇒ Object
Retrive a card list.
-
#card_members(card_id, options = {}) ⇒ Object
Retrieve card members.
-
#card_members_voted(card_id, options = {}) ⇒ Object
Retrieve members who voted on a card.
-
#check_item_states(card_id, options = {}) ⇒ Object
Retrieve card checklist item states.
-
#checklists(card_id, options = {}) ⇒ Object
Retrieve card checklists.
-
#convert_to_card(card_id, checklist_id, check_item_id) ⇒ Object
Convert a checklist item to a card.
-
#copy_checklist(card_id, checklist_id) ⇒ Object
Copy another checklist to card.
-
#create_card(list_id, name = nil, options = {}) ⇒ Object
Create a card.
-
#create_card_resource(card_id, resource, *paths) ⇒ Object
Create a card resource.
-
#delete_card(card_id) ⇒ Object
DELETE cards/[card id or shortlink].
-
#move_card(card_id, options) ⇒ Object
Move card to another position, board and/or list.
-
#remove_attachment(card_id, attachment_id) ⇒ Object
(also: #delete_attachement)
Remove an attachment.
-
#remove_card_member(card_id, member_id) ⇒ Object
(also: #delete_card_member)
Remove a member from a card.
-
#remove_checklist(card_id, checklist_id) ⇒ Object
(also: #delete_checklist)
Remove checklist.
-
#remove_comment(card_id, comment_id) ⇒ Object
(also: #delete_comment)
Remove a comment.
-
#remove_label(card_id, color) ⇒ Object
(also: #delete_label)
Remove label from card.
-
#remove_sticker(card_id, sticker_id) ⇒ Object
(also: #delete_sticker)
Remove a sticker from a card.
-
#remove_vote(card_id, member_id) ⇒ Object
(also: #delete_vote)
Remove a vote from a card.
-
#restore_card(card_id) ⇒ Object
Restore an archived card.
-
#stickers(card_id, options = {}) ⇒ Object
Retrieve card stickers.
-
#subscribe_to_card(card_id) ⇒ Object
Subscribe to card.
-
#unsubscribe_from_card(card_id) ⇒ Object
Unubscribe from card.
-
#update_card(card_id, options = {}) ⇒ Object
Update card attributes.
-
#update_card_name(card_id, name) ⇒ Object
Update card name.
-
#update_card_resource(card_id, resource, *paths) ⇒ Object
Update any card resource.
-
#update_check_item(card_id, checklist_id, check_item_id, options = {}) ⇒ Object
Update checklist item text, position or state.
-
#update_comment(card_id, comment_id, text, options = {}) ⇒ Object
(also: #edit_comment)
Update comment text.
-
#vote(card_id, member_id) ⇒ Object
(also: #create_vote)
Cast vote for card.
Instance Method Details
#add_checklist(card_id, name) ⇒ Object Also known as: start_checklist
Start a new checklist on card
207 208 209 |
# File 'lib/tacokit/client/cards.rb', line 207 def add_checklist(card_id, name) create_card_resource(card_id, "checklists", name: name) end |
#add_comment(card_id, text, options = {}) ⇒ Object Also known as: create_card_comment
Add a comment to a card
172 173 174 175 |
# File 'lib/tacokit/client/cards.rb', line 172 def add_comment(card_id, text, = {}) .update text: text create_card_resource card_id, "actions", "comments", end |
#add_label(card_id, color, options = {}) ⇒ Object
Add label to card
229 230 231 |
# File 'lib/tacokit/client/cards.rb', line 229 def add_label(card_id, color, = {}) create_card_resource(card_id, "labels", .merge(color: color)) end |
#add_member_to_card(card_id, member_id) ⇒ Object
Add a member to a card
222 223 224 |
# File 'lib/tacokit/client/cards.rb', line 222 def add_member_to_card(card_id, member_id) create_card_resource(card_id, "idMembers", value: member_id) end |
#add_sticker(card_id, image_name, options = {}) ⇒ Object Also known as: create_sticker
Add sticker to card
244 245 246 247 |
# File 'lib/tacokit/client/cards.rb', line 244 def add_sticker(card_id, image_name, = {}) defaults = { top: 0, left: 0, z_index: 1 } create_card_resource(card_id, "stickers", defaults.merge(.merge(image: image_name))) end |
#archive_card(card_id) ⇒ Object
Archive a card
113 114 115 |
# File 'lib/tacokit/client/cards.rb', line 113 def archive_card(card_id) update_card(card_id, closed: true) end |
#attach_file(card_id, url, mime_type = nil, options = {}) ⇒ Object Also known as: create_card_attachment
Attach a file to a card
181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/tacokit/client/cards.rb', line 181 def attach_file(card_id, url, mime_type = nil, = {}) = mime_type if mime_type.is_a?(Hash) uri = URI.parse(url) if uri.scheme =~ %r{https?} .update url: uri.to_s, mime_type: mime_type else file = Faraday::UploadIO.new(uri.to_s, mime_type) .update file: file, mime_type: file.content_type end create_card_resource card_id, "attachments", end |
#attachment(card_id, attachment_id, options = {}) ⇒ Object
Retrieve a card attachment
34 35 36 |
# File 'lib/tacokit/client/cards.rb', line 34 def (card_id, , = {}) card_resource(card_id, "attachments/#{}", ) end |
#attachments(card_id, options = {}) ⇒ Object Also known as: card_attachments
Retrieve card attachments
26 27 28 |
# File 'lib/tacokit/client/cards.rb', line 26 def (card_id, = {}) card_resource(card_id, "attachments", ) end |
#card(card_id, options = nil) ⇒ Object
Retrieve a card by id or shortlink
12 13 14 |
# File 'lib/tacokit/client/cards.rb', line 12 def card(card_id, = nil) get card_path(card_id), end |
#card_actions(card_id, options = {}) ⇒ Object
Retrieve card actions
19 20 21 |
# File 'lib/tacokit/client/cards.rb', line 19 def card_actions(card_id, = {}) paginated_card_resource(card_id, "actions", ) end |
#card_board(card_id, options = {}) ⇒ Object
Retrieve a card board
41 42 43 |
# File 'lib/tacokit/client/cards.rb', line 41 def card_board(card_id, = {}) card_resource(card_id, "board", ) end |
#card_list(card_id, options = {}) ⇒ Object
Retrive a card list
63 64 65 |
# File 'lib/tacokit/client/cards.rb', line 63 def card_list(card_id, = {}) card_resource(card_id, "list", ) end |
#card_members(card_id, options = {}) ⇒ Object
Retrieve card members
70 71 72 |
# File 'lib/tacokit/client/cards.rb', line 70 def card_members(card_id, = {}) card_resource(card_id, "members", ) end |
#card_members_voted(card_id, options = {}) ⇒ Object
Retrieve members who voted on a card
77 78 79 |
# File 'lib/tacokit/client/cards.rb', line 77 def card_members_voted(card_id, = {}) card_resource(card_id, "members_voted", ) end |
#check_item_states(card_id, options = {}) ⇒ Object
Retrieve card checklist item states
48 49 50 |
# File 'lib/tacokit/client/cards.rb', line 48 def check_item_states(card_id, = {}) card_resource(card_id, "check_item_states", ) end |
#checklists(card_id, options = {}) ⇒ Object
Retrieve card checklists
55 56 57 |
# File 'lib/tacokit/client/cards.rb', line 55 def checklists(card_id, = {}) card_resource(card_id, "checklists", ) end |
#convert_to_card(card_id, checklist_id, check_item_id) ⇒ Object
Convert a checklist item to a card
200 201 202 |
# File 'lib/tacokit/client/cards.rb', line 200 def convert_to_card(card_id, checklist_id, check_item_id) create_card_resource(card_id, "checklist", checklist_id, "checkItem", check_item_id, "convertToCard") end |
#copy_checklist(card_id, checklist_id) ⇒ Object
Copy another checklist to card
215 216 217 |
# File 'lib/tacokit/client/cards.rb', line 215 def copy_checklist(card_id, checklist_id) create_card_resource(card_id, "checklists", checklist_source_id: checklist_id) end |
#create_card(list_id, name = nil, options = {}) ⇒ Object
Create a card
165 166 167 |
# File 'lib/tacokit/client/cards.rb', line 165 def create_card(list_id, name = nil, = {}) post "cards", .merge(name: name, list_id: list_id) end |
#create_card_resource(card_id, resource, *paths) ⇒ Object
Create a card resource
252 253 254 255 |
# File 'lib/tacokit/client/cards.rb', line 252 def create_card_resource(card_id, resource, *paths) paths, = (camp(resource), *paths) post card_path(card_id, *paths), end |
#delete_card(card_id) ⇒ Object
DELETE cards/[card id or shortlink]
260 261 262 |
# File 'lib/tacokit/client/cards.rb', line 260 def delete_card(card_id) delete card_path(card_id) end |
#move_card(card_id, options) ⇒ Object
Move card to another position, board and/or list
128 129 130 131 132 133 |
# File 'lib/tacokit/client/cards.rb', line 128 def move_card(card_id, ) unless .is_a?(Hash) && ([:board_id, :list_id, :pos].any? { |key| .key? key }) raise ArgumentError, "Required option: :pos, :board_id and/or :list_id" end update_card(card_id, ) end |
#remove_attachment(card_id, attachment_id) ⇒ Object Also known as: delete_attachement
Remove an attachment
275 276 277 |
# File 'lib/tacokit/client/cards.rb', line 275 def (card_id, ) delete_card_resource card_id, "attachments", end |
#remove_card_member(card_id, member_id) ⇒ Object Also known as: delete_card_member
Remove a member from a card
291 292 293 |
# File 'lib/tacokit/client/cards.rb', line 291 def remove_card_member(card_id, member_id) delete_card_resource card_id, "idMembers", member_id end |
#remove_checklist(card_id, checklist_id) ⇒ Object Also known as: delete_checklist
Remove checklist
283 284 285 |
# File 'lib/tacokit/client/cards.rb', line 283 def remove_checklist(card_id, checklist_id) delete_card_resource card_id, "checklists", checklist_id end |
#remove_comment(card_id, comment_id) ⇒ Object Also known as: delete_comment
Remove a comment
267 268 269 |
# File 'lib/tacokit/client/cards.rb', line 267 def remove_comment(card_id, comment_id) delete_card_resource card_id, "actions", comment_id, "comments" end |
#remove_label(card_id, color) ⇒ Object Also known as: delete_label
Remove label from card
299 300 301 |
# File 'lib/tacokit/client/cards.rb', line 299 def remove_label(card_id, color) delete_card_resource card_id, "labels", color end |
#remove_sticker(card_id, sticker_id) ⇒ Object Also known as: delete_sticker
Remove a sticker from a card
315 316 317 |
# File 'lib/tacokit/client/cards.rb', line 315 def remove_sticker(card_id, sticker_id) delete_card_resource card_id, "stickers", sticker_id end |
#remove_vote(card_id, member_id) ⇒ Object Also known as: delete_vote
Remove a vote from a card
307 308 309 |
# File 'lib/tacokit/client/cards.rb', line 307 def remove_vote(card_id, member_id) delete_card_resource card_id, "membersVoted", member_id end |
#restore_card(card_id) ⇒ Object
Restore an archived card
120 121 122 |
# File 'lib/tacokit/client/cards.rb', line 120 def restore_card(card_id) update_card(card_id, closed: false) end |
#stickers(card_id, options = {}) ⇒ Object
Retrieve card stickers
84 85 86 |
# File 'lib/tacokit/client/cards.rb', line 84 def stickers(card_id, = {}) card_resource(card_id, "stickers", ) end |
#subscribe_to_card(card_id) ⇒ Object
Subscribe to card
145 146 147 |
# File 'lib/tacokit/client/cards.rb', line 145 def subscribe_to_card(card_id) put card_path(card_id, "subscribed"), value: true end |
#unsubscribe_from_card(card_id) ⇒ Object
Unubscribe from card
152 153 154 |
# File 'lib/tacokit/client/cards.rb', line 152 def unsubscribe_from_card(card_id) put card_path(card_id, "subscribed"), value: false end |
#update_card(card_id, options = {}) ⇒ Object
Update card attributes
91 92 93 |
# File 'lib/tacokit/client/cards.rb', line 91 def update_card(card_id, = {}) put card_path(card_id), end |
#update_card_name(card_id, name) ⇒ Object
Update card name
138 139 140 |
# File 'lib/tacokit/client/cards.rb', line 138 def update_card_name(card_id, name) put card_path(card_id, "name"), value: name end |
#update_card_resource(card_id, resource, *paths) ⇒ Object
Update any card resource
157 158 159 160 |
# File 'lib/tacokit/client/cards.rb', line 157 def update_card_resource(card_id, resource, *paths) paths, = (camp(resource), *paths) put card_path(card_id, *paths), end |
#update_check_item(card_id, checklist_id, check_item_id, options = {}) ⇒ Object
Update checklist item text, position or state
106 107 108 |
# File 'lib/tacokit/client/cards.rb', line 106 def update_check_item(card_id, checklist_id, check_item_id, = {}) update_card_resource(card_id, "checklist", checklist_id, "checkItem", check_item_id, ) end |
#update_comment(card_id, comment_id, text, options = {}) ⇒ Object Also known as: edit_comment
Update comment text
98 99 100 |
# File 'lib/tacokit/client/cards.rb', line 98 def update_comment(card_id, comment_id, text, = {}) update_card_resource(card_id, "actions", comment_id, "comments", .merge(text: text)) end |
#vote(card_id, member_id) ⇒ Object Also known as: create_vote
Cast vote for card
236 237 238 |
# File 'lib/tacokit/client/cards.rb', line 236 def vote(card_id, member_id) create_card_resource(card_id, "membersVoted", value: member_id) end |