module Tr3llo::API::Label
Public Instance Methods
create(name:, color:, board_id:)
click to toggle source
# File lib/3llo/api/label.rb, line 27 def create(name:, color:, board_id:) req_path = Utils.build_req_path("/labels") payload = { "name" => name, "color" => color, "idBoard" => board_id } client.post(req_path, {}, payload) end
delete(label_id)
click to toggle source
# File lib/3llo/api/label.rb, line 44 def delete(label_id) req_path = Utils.build_req_path("/labels/#{label_id}") client.delete(req_path, {}, {}) end
find(label_id)
click to toggle source
# File lib/3llo/api/label.rb, line 20 def find(label_id) req_path = Utils.build_req_path("/labels/#{label_id}") label_payload = client.get(req_path, {}) make_struct(label_payload) end
find_all_by_board(board_id)
click to toggle source
# File lib/3llo/api/label.rb, line 6 def find_all_by_board(board_id) req_path = Utils.build_req_path( "/boards/#{board_id}/labels" ) client .get(req_path, {}) .reject { |label| label["name"].empty? } .map do |label_payload| make_struct(label_payload) end end
update(label_id, data)
click to toggle source
# File lib/3llo/api/label.rb, line 38 def update(label_id, data) req_path = Utils.build_req_path("/labels/#{label_id}") client.put(req_path, {}, data) end
Private Instance Methods
client()
click to toggle source
# File lib/3llo/api/label.rb, line 59 def client Application.fetch_client!() end
make_struct(payload)
click to toggle source
# File lib/3llo/api/label.rb, line 52 def make_struct(payload) id, name, color = payload.fetch_values("id", "name", "color") shortcut = Entities.make_shortcut(:label, id) Entities::Label.new(id: id, shortcut: shortcut, name: name, color: color) end