From bc04aa712d45b0254c72a6daeed37021ae1bfce3 Mon Sep 17 00:00:00 2001 From: Amy Joseph Date: Tue, 24 Apr 2018 15:38:13 +0100 Subject: [PATCH 1/2] Add method to create labels on a board Takes board id, color and name of label. Checks color is valid and creates label on the board. --- lib/Trello/Api/Board/Labels.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/Trello/Api/Board/Labels.php b/lib/Trello/Api/Board/Labels.php index f924f76..0c50fe5 100644 --- a/lib/Trello/Api/Board/Labels.php +++ b/lib/Trello/Api/Board/Labels.php @@ -84,4 +84,29 @@ public function setName($id, $color, $name) return $this->put('boards/'.rawurlencode($id).'/labelNames/'.rawurlencode($color), array('value' => $name)); } + + /** + * Create a list on a given board + * @link https://trello.com/docs/api/board/#post-1-boards-board-id-lists + * + * @param string $id the board's id + * @param string $color the label color to set the name of + * @param string $name + * + * @return array + */ + public function create($id, $color, $name) + { + $colors = array('blue', 'green', 'orange', 'purple', 'red', 'yellow'); + + if (!in_array($color, $colors)) { + throw new InvalidArgumentException(sprintf( + 'The "color" parameter must be one of "%s".', + implode(", ", $colors) + )); + } + + return $this->post('boards/'.rawurlencode($id).'/labels/', array('name' => $name, 'color' => $color)); + } +} } From ccbab3a06fad81bf5134360a01d591d81cb88c7a Mon Sep 17 00:00:00 2001 From: Amy Joseph Date: Tue, 24 Apr 2018 15:53:45 +0100 Subject: [PATCH 2/2] Add method to create labels on a board Fix bug Takes board id, color and name of label. Checks color is valid and creates label on the board. --- lib/Trello/Api/Board/Labels.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Trello/Api/Board/Labels.php b/lib/Trello/Api/Board/Labels.php index 0c50fe5..356dbcf 100644 --- a/lib/Trello/Api/Board/Labels.php +++ b/lib/Trello/Api/Board/Labels.php @@ -109,4 +109,3 @@ public function create($id, $color, $name) return $this->post('boards/'.rawurlencode($id).'/labels/', array('name' => $name, 'color' => $color)); } } -}