Module: Tr3llo::API::Label

Extended by:
Label
Included in:
Label
Defined in:
lib/3llo/api/label.rb

Instance Method Summary collapse

Instance Method Details

#create(name:, color:, board_id:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# 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) ⇒ Object



44
45
46
47
48
# 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) ⇒ Object



20
21
22
23
24
25
# 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) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# 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) ⇒ Object



38
39
40
41
42
# 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