1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Trello\Api; |
4
|
|
|
|
5
|
|
|
use Trello\Exception\InvalidArgumentException; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Trello Checkist API |
9
|
|
|
* @link https://trello.com/docs/api/checklist |
10
|
|
|
* |
11
|
|
|
* Fully implemented. |
12
|
|
|
*/ |
13
|
|
|
class Checklist extends AbstractApi |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* Base path of checklists api |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
protected $path = 'checklists'; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* Card fields |
23
|
|
|
* @link https://trello.com/docs/api/list/#get-1-lists-list-id-or-shortlink-field |
24
|
|
|
* @var array |
25
|
|
|
*/ |
26
|
|
|
public static $fields = array( |
27
|
|
|
'name', |
28
|
|
|
'idBoard', |
29
|
|
|
'idCard', |
30
|
|
|
'pos', |
31
|
|
|
); |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Find a list by id |
35
|
|
|
* @link https://trello.com/docs/api/checklist/#get-1-checklists-idchecklist |
36
|
|
|
* |
37
|
|
|
* @param string $id the checklist's id |
38
|
|
|
* @param array $params optional attributes |
39
|
|
|
* |
40
|
|
|
* @return array list info |
41
|
|
|
*/ |
42
|
1 |
|
public function show($id, array $params = array()) |
43
|
|
|
{ |
44
|
1 |
|
return $this->get($this->getPath().'/'.rawurlencode($id), $params); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Create a checklist |
49
|
|
|
* @link https://trello.com/docs/api/checklist/#post-1-checklists |
50
|
|
|
* |
51
|
|
|
* @param array $params optional attributes: 'name', 'idBoard', 'idCard', 'pos', 'idChecklistSource' |
52
|
|
|
* |
53
|
|
|
* @return array |
54
|
|
|
*/ |
55
|
3 |
|
public function create(array $params = array()) |
56
|
|
|
{ |
57
|
3 |
|
$this->validateRequiredParameters(array('name', 'idCard'), $params); |
58
|
|
|
|
59
|
1 |
|
return $this->post($this->getPath(), $params); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Update a checklist |
64
|
|
|
* @link https://trello.com/docs/api/checklist/#put-1-checklists-idchecklist |
65
|
|
|
* |
66
|
|
|
* @param string $id the list's id |
67
|
|
|
* @param array $params list attributes to update |
68
|
|
|
* |
69
|
|
|
* @return array list info |
70
|
|
|
*/ |
71
|
1 |
|
public function update($id, array $params = array()) |
72
|
|
|
{ |
73
|
1 |
|
return $this->put($this->getPath().'/'.rawurlencode($id), $params); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Remove a checklist |
78
|
|
|
* @link https://trello.com/docs/api/checklist/#delete-1-checklists-idchecklist |
79
|
|
|
* |
80
|
|
|
* @param string $id the checklist's id |
81
|
|
|
* |
82
|
|
|
* @return array |
83
|
|
|
*/ |
84
|
1 |
|
public function remove($id) |
85
|
|
|
{ |
86
|
1 |
|
return $this->delete($this->getPath().'/'.rawurlencode($id)); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Remove a listitem from a checklist |
91
|
|
|
* @link https://trello.com/docs/api/checklist/index.html#delete-1-checklists-idchecklist-checkitems-idcheckitem |
92
|
|
|
* |
93
|
|
|
* @param string $checkListId the checklist's id |
94
|
|
|
* @param string $listItemId the listItem id |
95
|
|
|
* |
96
|
|
|
* @return array |
97
|
|
|
*/ |
98
|
1 |
|
public function removeListItem($checkListId, $listItemId) |
99
|
|
|
{ |
100
|
1 |
|
return $this->delete($this->getPath().'/'.rawurlencode($checkListId).'/checkItems/'.rawurlencode($listItemId)); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* get checklist items from a checklist |
106
|
|
|
* @link https://trello.readme.io/v1.0/reference#checklistsidcardscheckitems |
107
|
|
|
* |
108
|
|
|
* @param string $checkListId the checklist's id |
109
|
|
|
* @param string $listItemId (optional) the listItem id |
|
|
|
|
110
|
|
|
* @param array $fields (options) the fields to retrieve |
111
|
|
|
* |
112
|
|
|
* @return array |
113
|
|
|
*/ |
114
|
2 |
|
public function getListItems($checkListId, array $fields = array('fields' => 'all')) |
115
|
|
|
{ |
116
|
2 |
|
return $this->get($this->getPath().'/'.rawurlencode($checkListId).'/checkItems', $fields); |
117
|
|
|
} |
118
|
1 |
|
|
119
|
|
|
/** |
120
|
|
|
* get a specific checklist item from a checklist |
121
|
|
|
* @link https://trello.readme.io/v1.0/reference#checklistsidcardscheckitems |
122
|
|
|
* |
123
|
|
|
* @param string $checkListId the checklist's id |
124
|
|
|
* @param string $listItemId the listItem id |
125
|
|
|
* @param array $fields (options) the fields to retrieve |
126
|
|
|
* |
127
|
|
|
* @return array |
128
|
|
|
*/ |
129
|
|
|
public function getListItem($checkListId, $listItemId, array $fields = array('fields' => 'all')) |
130
|
1 |
|
{ |
131
|
|
|
return $this->get($this->getPath().'/'.rawurlencode($checkListId).'/checkItem/'.rawurlencode($listItemId), $fields); |
132
|
1 |
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* Get the board of a given checklist |
136
|
|
|
* @link https://trello.com/docs/api/checklist/#get-1-checklists-idchecklist-board |
137
|
|
|
* |
138
|
|
|
* @param string $id the checklist's id |
139
|
|
|
* @param array $params optional parameters |
140
|
|
|
* |
141
|
|
|
* @return array board info |
142
|
|
|
*/ |
143
|
|
|
public function getBoard($id, array $params = array()) |
144
|
1 |
|
{ |
145
|
|
|
return $this->get($this->getPath().'/'.rawurlencode($id).'/board', $params); |
146
|
1 |
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* Get the field of a board of a given checklist |
150
|
|
|
* @link https://trello.com/docs/api/checklist/#get-1-checklists-idchecklist-board-field |
151
|
|
|
* |
152
|
|
|
* @param string $id the checklist's id |
153
|
|
|
* @param array $field the name of the field |
154
|
|
|
* |
155
|
|
|
* @return array board info |
156
|
|
|
* |
157
|
|
|
* @throws InvalidArgumentException if the field does not exist |
158
|
|
|
*/ |
159
|
1 |
|
public function getBoardField($id, $field) |
160
|
|
|
{ |
161
|
1 |
|
$this->validateAllowedParameters(Board::$fields, $field, 'field'); |
162
|
|
|
|
163
|
|
|
return $this->get($this->getPath().'/'.rawurlencode($id).'/board/'.rawurlencode($field)); |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Set a given checklist's card |
168
|
|
|
* @link https://trello.com/docs/api/checklist/#put-1-checklists-idchecklist-idcard |
169
|
1 |
|
* |
170
|
|
|
* @param string $id the list's id |
171
|
1 |
|
* @param string $cardId the card's id |
172
|
|
|
* |
173
|
|
|
* @return array |
174
|
|
|
*/ |
175
|
|
|
public function setCard($id, $cardId) |
176
|
|
|
{ |
177
|
|
|
return $this->put($this->getPath().'/'.rawurlencode($id).'/idCard', array('value' => $cardId)); |
178
|
|
|
} |
179
|
1 |
|
|
180
|
|
|
/** |
181
|
1 |
|
* Set a given checklist's name |
182
|
|
|
* @link https://trello.com/docs/api/checklist/#put-1-checklists-idchecklist-name |
183
|
|
|
* |
184
|
|
|
* @param string $id the checklist's id |
185
|
|
|
* @param string $name the name |
186
|
|
|
* |
187
|
|
|
* @return array |
188
|
|
|
*/ |
189
|
|
|
public function setName($id, $name) |
190
|
|
|
{ |
191
|
|
|
return $this->put($this->getPath().'/'.rawurlencode($id).'/name', array('value' => $name)); |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* Set a given checklist's position |
196
|
|
|
* @link https://trello.com/docs/api/checklist/#put-1-checklists-idchecklist-pos |
197
|
|
|
* |
198
|
|
|
* @param string $id the list's id |
199
|
|
|
* @param string|integer $position the position, eg. 'top', 'bottom' |
200
|
|
|
* or a positive number |
201
|
|
|
* |
202
|
|
|
* @return array list info |
203
|
|
|
*/ |
204
|
|
|
public function setPosition($id, $position) |
205
|
|
|
{ |
206
|
|
|
return $this->put($this->getPath().'/'.rawurlencode($id).'/pos', array('value' => $position)); |
207
|
|
|
} |
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Cards API |
211
|
|
|
* |
212
|
|
|
* @return Checklist\Cards |
213
|
|
|
*/ |
214
|
|
|
public function cards() |
215
|
|
|
{ |
216
|
|
|
return new Checklist\Cards($this->client); |
217
|
|
|
} |
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* Items API |
221
|
|
|
* |
222
|
|
|
* @return Checklist\Items |
223
|
|
|
*/ |
224
|
|
|
public function items() |
225
|
|
|
{ |
226
|
|
|
return new Checklist\Items($this->client); |
227
|
|
|
} |
228
|
|
|
} |
229
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.