Module: Tr3llo::API::Card
Instance Method Summary collapse
- #add_labels(card_id, labels) ⇒ Object
-
#archive(card_id) ⇒ Object
TODO: Use “.update”.
-
#assign_members(card_id, members) ⇒ Object
TODO: Use “.update”.
- #comment(card_id, text) ⇒ Object
- #create(name, description, list_id) ⇒ Object
- #find(card_id) ⇒ Object
- #find_all_by_list(list_id) ⇒ Object
- #find_all_by_user(board_id, user_id) ⇒ Object
- #list_comments(card_id) ⇒ Object
-
#move_to_list(card_id, list_id) ⇒ Object
TODO: Use “.update”.
- #update(card_id, data) ⇒ Object
Instance Method Details
#add_labels(card_id, labels) ⇒ Object
119 120 121 122 123 |
# File 'lib/3llo/api/card.rb', line 119 def add_labels(card_id, labels) req_path = Utils.build_req_path("/cards/#{card_id}/idLabels") client.put(req_path, {}, {"value" => labels.join(",")}) end |
#archive(card_id) ⇒ Object
TODO: Use “.update”.
112 113 114 115 116 117 |
# File 'lib/3llo/api/card.rb', line 112 def archive(card_id) req_path = Utils.build_req_path("/cards/#{card_id}") payload = {"closed" => "true"} client.put(req_path, {}, payload) end |
#assign_members(card_id, members) ⇒ Object
TODO: Use “.update”.
71 72 73 74 75 |
# File 'lib/3llo/api/card.rb', line 71 def assign_members(card_id, members) req_path = Utils.build_req_path("/cards/#{card_id}/idMembers") client.put(req_path, {}, {"value" => members.join(",")}) end |
#comment(card_id, text) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/3llo/api/card.rb', line 104 def comment(card_id, text) req_path = Utils.build_req_path("/cards/#{card_id}/actions/comments") payload = {"text" => text} client.post(req_path, {}, payload) end |
#create(name, description, list_id) ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/3llo/api/card.rb', line 34 def create(name, description, list_id) req_path = Utils.build_req_path("/cards", {}) payload = { "name" => name, "desc" => description, "idList" => list_id } client.post(req_path, {}, payload) end |
#find(card_id) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/3llo/api/card.rb', line 51 def find(card_id) req_path = Utils.build_req_path( "/cards/#{card_id}", {"list" => "true", "members" => "true"} ) card_payload = client.get(req_path, {}) make_struct(card_payload) end |
#find_all_by_list(list_id) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/3llo/api/card.rb', line 6 def find_all_by_list(list_id) req_path = Utils.build_req_path( "/lists/#{list_id}/cards", {"members" => "true", "member_fields" => "id,username"} ) client .get(req_path, {}) .map do |card_payload| make_struct(card_payload) end end |
#find_all_by_user(board_id, user_id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/3llo/api/card.rb', line 20 def find_all_by_user(board_id, user_id) req_path = Utils.build_req_path( "/boards/#{board_id}/members/#{user_id}/cards", {"list" => "true"} ) client .get(req_path, {}) .map do |card_payload| make_struct(card_payload) end end |
#list_comments(card_id) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/3llo/api/card.rb', line 77 def list_comments(card_id) req_path = Utils.build_req_path( "/cards/#{card_id}/actions", {"filter" => "commentCard"} ) client .get(req_path, {}) .map do |comment_payload| id, creator_payload, date = comment_payload.fetch_values("id", "memberCreator", "date") text = comment_payload.dig("data", "text") created_at = DateTime.iso8601(date) creator_id, creator_username = creator_payload.fetch_values("id", "username") creator = Entities::User.new(creator_id, _creator_shortcut = nil, creator_username) Entities::Comment.new( id: id, creator: creator, created_at: created_at, text: text ) end end |
#move_to_list(card_id, list_id) ⇒ Object
TODO: Use “.update”.
64 65 66 67 68 |
# File 'lib/3llo/api/card.rb', line 64 def move_to_list(card_id, list_id) req_path = Utils.build_req_path("/cards/#{card_id}/idList") client.put(req_path, {}, {"value" => list_id}) end |
#update(card_id, data) ⇒ Object
45 46 47 48 49 |
# File 'lib/3llo/api/card.rb', line 45 def update(card_id, data) req_path = Utils.build_req_path("/cards/#{card_id}") client.put(req_path, {}, data) end |