1 | <?php |
||
16 | class Card extends AbstractApi |
||
17 | { |
||
18 | /** |
||
19 | * Base path of cards api |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $path = 'cards'; |
||
23 | |||
24 | /** |
||
25 | * Card fields |
||
26 | * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-field |
||
27 | * @var array |
||
28 | */ |
||
29 | public static $fields = array( |
||
30 | 'badges', |
||
31 | 'checkItemStates', |
||
32 | 'closed', |
||
33 | 'dateLastActivity', |
||
34 | 'desc', |
||
35 | 'descData', |
||
36 | 'due', |
||
37 | 'email', |
||
38 | 'idBoard', |
||
39 | 'idChecklists', |
||
40 | 'idList', |
||
41 | 'idMembers', |
||
42 | 'idMembersVoted', |
||
43 | 'idShort', |
||
44 | 'idAttachmentCover', |
||
45 | 'manualCoverAttachment', |
||
46 | 'labels', |
||
47 | 'name', |
||
48 | 'pos', |
||
49 | 'shortLink', |
||
50 | 'shortUrl', |
||
51 | 'subscribed', |
||
52 | 'url', |
||
53 | ); |
||
54 | |||
55 | /** |
||
56 | * Find a card by id |
||
57 | * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink |
||
58 | * |
||
59 | * @param string $id the card's id or short link |
||
60 | * @param array $params optional attributes |
||
61 | * |
||
62 | * @return array card info |
||
63 | */ |
||
64 | public function show($id, array $params = array()) |
||
68 | 1 | ||
69 | /** |
||
70 | 1 | * Create a card |
|
71 | * @link https://trello.com/docs/api/card/#post-1-cards |
||
72 | * |
||
73 | * @param array $params optional attributes |
||
74 | * |
||
75 | * @return array card info |
||
76 | */ |
||
77 | public function create(array $params = array()) |
||
90 | 1 | ||
91 | /** |
||
92 | 1 | * Create a checklist Item |
|
93 | * @link https://trello.com/docs/api/card/#post-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem |
||
94 | * |
||
95 | * @param string $cardId id of the card the item is added to |
||
96 | * @param string $checkListId id of the checklist the item is added to |
||
97 | * @param array $params optional attributes |
||
98 | * |
||
99 | * @return array card info |
||
100 | */ |
||
101 | |||
102 | public function createCheckListItem($cardId, $checkListId, $params = Array()){ |
||
108 | |||
109 | /** |
||
110 | * Update a card |
||
111 | * @link https://trello.com/docs/api/card/#put-1-cards |
||
112 | * |
||
113 | * @param string $id the card's id or short link |
||
114 | * @param array $params card attributes to update |
||
115 | * |
||
116 | * @return array card info |
||
117 | */ |
||
118 | 1 | public function update($id, array $params = array()) |
|
122 | |||
123 | /** |
||
124 | * Set a given card's board |
||
125 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-idboard |
||
126 | * |
||
127 | * @param string $id the card's id or short link |
||
128 | * @param string $boardId the board's id |
||
129 | * |
||
130 | * @return array board info |
||
131 | */ |
||
132 | 1 | public function setBoard($id, $boardId) |
|
136 | |||
137 | /** |
||
138 | * Get a given card's board |
||
139 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-idboard |
||
140 | * |
||
141 | * @param string $id the card's id or short link |
||
142 | * @param array $params optional parameters |
||
143 | * |
||
144 | * @return array board info |
||
145 | */ |
||
146 | public function getBoard($id, array $params = array()) |
||
150 | 2 | ||
151 | /** |
||
152 | 1 | * Get the field of a board of a given card |
|
153 | * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-board-field |
||
154 | * |
||
155 | * @param string $id the card's id |
||
156 | * @param array $field the name of the field |
||
157 | * |
||
158 | * @return array board info |
||
159 | * |
||
160 | * @throws InvalidArgumentException if the field does not exist |
||
161 | */ |
||
162 | public function getBoardField($id, $field) |
||
168 | |||
169 | /** |
||
170 | * Get the checkitemstates, for now will return the full list of checkitem states; |
||
171 | * @link https://trello.com/docs/api/card/index.html#get-1-cards-card-id-or-shortlink-checkitemstates |
||
172 | * |
||
173 | * @param string $id the card's id or short link |
||
174 | * |
||
175 | * @return array list info |
||
176 | */ |
||
177 | public function getCheckItemStates($id){ |
||
181 | |||
182 | /** |
||
183 | * Get the members; |
||
184 | * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-members |
||
185 | * |
||
186 | * @param string $id the card's id or short link |
||
187 | * |
||
188 | * @return array list info |
||
189 | */ |
||
190 | public function getMembers($id){ |
||
193 | /** |
||
194 | 2 | * Set a given card's list |
|
195 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-idlist |
||
196 | 2 | * |
|
197 | * @param string $id the card's id or short link |
||
198 | 1 | * @param string $listId the list's id |
|
199 | * |
||
200 | * @return array list info |
||
201 | */ |
||
202 | public function setList($id, $listId) |
||
206 | |||
207 | /** |
||
208 | * Get a given card's list |
||
209 | * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-list |
||
210 | 1 | * |
|
211 | * @param string $id the card's id or short link |
||
212 | 1 | * @param array $params optional parameters |
|
213 | * |
||
214 | * @return array list info |
||
215 | */ |
||
216 | public function getList($id, array $params = array()) |
||
220 | |||
221 | /** |
||
222 | * Get the field of a list of a given card |
||
223 | * @link https://trello.com/docs/api/card/#get-1-cards-card-id-or-shortlink-list-field |
||
224 | 1 | * |
|
225 | * @param string $id the card's id |
||
226 | 1 | * @param array $field the name of the field |
|
227 | * |
||
228 | * @return array board info |
||
229 | * |
||
230 | * @throws InvalidArgumentException if the field does not exist |
||
231 | */ |
||
232 | public function getListField($id, $field) |
||
238 | 1 | ||
239 | /** |
||
240 | 1 | * Set a given card's name |
|
241 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-name |
||
242 | * |
||
243 | * @param string $id the card's id or short link |
||
244 | * @param string $name the name |
||
245 | * |
||
246 | * @return array card info |
||
247 | */ |
||
248 | public function setName($id, $name) |
||
252 | 1 | ||
253 | /** |
||
254 | 1 | * Set a given card's description |
|
255 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-desc |
||
256 | * |
||
257 | * @param string $id the card's id or short link |
||
258 | * @param string $description the description |
||
259 | * |
||
260 | * @return array card info |
||
261 | */ |
||
262 | public function setDescription($id, $description) |
||
266 | |||
267 | 1 | /** |
|
268 | * Set a given card's state |
||
269 | 1 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-closed |
|
270 | * |
||
271 | * @param string $id the card's id or short link |
||
272 | * @param bool $closed whether the card should be closed or not |
||
273 | * |
||
274 | * @return array card info |
||
275 | */ |
||
276 | public function setClosed($id, $closed = true) |
||
280 | |||
281 | 1 | /** |
|
282 | * Set a given card's due date |
||
283 | 1 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-due |
|
284 | * |
||
285 | * @param string $id the card's id or short link |
||
286 | * @param \DateTime $date the due date |
||
287 | * |
||
288 | * @return array card info |
||
289 | */ |
||
290 | public function setDueDate($id, \DateTime $date = null) |
||
294 | |||
295 | /** |
||
296 | * Set a given card's position |
||
297 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-pos |
||
298 | * |
||
299 | * @param string $id the card's id or short link |
||
300 | * @param string|integer $position the position, eg. 'top', 'bottom' |
||
301 | 1 | * or a positive number |
|
302 | * |
||
303 | 1 | * @return array card info |
|
304 | */ |
||
305 | public function setPosition($id, $position) |
||
309 | |||
310 | /** |
||
311 | 1 | * Set a given card's subscription state |
|
312 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-subscribed |
||
313 | 1 | * |
|
314 | * @param string $id the list's id |
||
315 | * @param bool $subscribed subscription state |
||
316 | * |
||
317 | * @return array list info |
||
318 | */ |
||
319 | public function setSubscribed($id, $subscribed) |
||
323 | 1 | ||
324 | |||
325 | /** |
||
326 | * Set a given card's memberId |
||
327 | * @link tbd |
||
328 | * |
||
329 | * @param string $id the list's id |
||
330 | * @param string $idMembers comma seperated list of responsible members |
||
331 | 1 | * |
|
332 | * @return array list info |
||
333 | 1 | */ |
|
334 | public function setIdMembers($id, $idMembers) |
||
338 | |||
339 | /** |
||
340 | * Set a given checklist item name |
||
341 | 1 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-name |
|
342 | * |
||
343 | 1 | * @param string $cardId the cards's id |
|
344 | * @param string $checkListId the checklist's id |
||
345 | * @param string $itemId the item's id |
||
346 | * @param string $name new name value |
||
347 | * |
||
348 | * @return array list info |
||
349 | */ |
||
350 | public function setCheckListItemName($cardId,$checkListId,$itemId, $name) |
||
354 | |||
355 | /** |
||
356 | * Set a given checklist item position |
||
357 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-pos |
||
358 | * |
||
359 | * @param string $cardId the cards's id |
||
360 | * @param string $checkListId the checklist's id |
||
361 | * @param string $itemId the item's id |
||
362 | * @param string $position new position value |
||
363 | * |
||
364 | * @return array list info |
||
365 | */ |
||
366 | public function setCheckListItemPosition($cardId,$checkListId,$itemId, $position) |
||
370 | |||
371 | /** |
||
372 | * Set a given checklist item closed state |
||
373 | * @link https://trello.com/docs/api/card/#put-1-cards-card-id-or-shortlink-checklist-idchecklist-checkitem-idcheckitem-state |
||
374 | * |
||
375 | * @param string $cardId the cards's id |
||
376 | * @param string $checkListId the checklist's id |
||
377 | * @param string $itemId the item's id |
||
378 | * @param bool $complete new complete value, defaults to true |
||
379 | * |
||
380 | * @return array list info |
||
381 | */ |
||
382 | public function setCheckListItemClosed($cardId,$checkListId,$itemId, $complete = true) |
||
386 | |||
387 | /** |
||
388 | * Update checklist item by parameter array |
||
389 | * @link https://trello.com/docs/api/card/index.html#put-1-cards-card-id-or-shortlink-checklist-idchecklistcurrent-checkitem-idcheckitem |
||
390 | * |
||
391 | * @param string $cardId the cards's id |
||
392 | * @param string $checkListId the checklist's id |
||
393 | * @param string $itemId the item's id |
||
394 | * @param array $params item attributes to update |
||
395 | * |
||
396 | * @return array list info |
||
397 | */ |
||
398 | public function updateCheckListItem($cardId,$checkListId,$itemId, $params = array()) |
||
402 | |||
403 | /** |
||
404 | * Get checkitem from a given card |
||
405 | * @link https://trello.readme.io/v1.0/reference#cardsidcheckitemidcheckitem-2 |
||
406 | * |
||
407 | * @param string $id the card's id or short link |
||
408 | * @param string $checkItemId the check item id |
||
409 | * @param array $params the parameter array to retrieve, default is to retrieve all fields |
||
410 | * |
||
411 | * @return array |
||
412 | */ |
||
413 | public function getCheckItem($id, $checkItemId, array $params = array('fields'=> 'all')) |
||
417 | |||
418 | /** |
||
419 | * Update checkItem for a given card |
||
420 | * @link https://trello.readme.io/v1.0/reference#cardsidcheckitemidcheckitem-1 |
||
421 | * |
||
422 | * @param string $id the card's id or short link |
||
423 | * @param string $checkItemId the check item id |
||
424 | * @param array $updateFields the fields that should be updated |
||
425 | * @return array |
||
426 | */ |
||
427 | public function updateCheckItem($id, $checkItemId, array $updateFields = array()) |
||
431 | |||
432 | /** |
||
433 | * Remove checkitem from a given card |
||
434 | * @link https://trello.readme.io/v1.0/reference#cardsidcheckitemidcheckitem-2 |
||
435 | * |
||
436 | * @param string $id the card's id or short link |
||
437 | * @param string $checkItemId the checklist item id |
||
438 | * |
||
439 | * @return array |
||
440 | */ |
||
441 | public function removeCheckItem($id, $checkItemId) |
||
445 | |||
446 | /** |
||
447 | * Actions API |
||
448 | * |
||
449 | * @return Card\Actions |
||
450 | */ |
||
451 | public function actions() |
||
455 | |||
456 | /** |
||
457 | * Attachments API |
||
458 | * |
||
459 | * @return Card\Attachments |
||
460 | */ |
||
461 | public function attachments() |
||
465 | |||
466 | /** |
||
467 | * Checklists API |
||
468 | * |
||
469 | * @return Card\Checklists |
||
470 | */ |
||
471 | public function checklists() |
||
475 | |||
476 | /** |
||
477 | * Labels API |
||
478 | * |
||
479 | * @return Card\Labels |
||
480 | */ |
||
481 | public function labels() |
||
485 | |||
486 | /** |
||
487 | * Members API |
||
488 | * |
||
489 | * @return Card\Members |
||
490 | */ |
||
491 | public function members() |
||
495 | |||
496 | /** |
||
497 | * Stickers API |
||
498 | * |
||
499 | * @return Card\Stickers |
||
500 | */ |
||
501 | public function stickers() |
||
505 | } |
||
506 |