|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Trello\Api\Cardlist; |
|
4
|
|
|
|
|
5
|
|
|
use Trello\Api\AbstractApi; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Trello List Cards API |
|
9
|
|
|
* @link https://trello.com/docs/api/list |
|
10
|
|
|
* |
|
11
|
|
|
* Fully implemented. |
|
12
|
|
|
*/ |
|
13
|
|
|
class Cards extends AbstractApi |
|
14
|
|
|
{ |
|
15
|
|
|
protected $path = 'lists/#id#/cards'; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Get cards related to a given list |
|
19
|
|
|
* @link https://trello.com/docs/api/list/#get-1-lists-idlist-cards |
|
20
|
|
|
* |
|
21
|
|
|
* @param string $id the card's id or short link |
|
22
|
|
|
* @param array $params optional parameters |
|
23
|
|
|
* |
|
24
|
|
|
* @return array |
|
25
|
|
|
*/ |
|
26
|
1 |
|
public function all($id, array $params = array()) |
|
27
|
|
|
{ |
|
28
|
1 |
|
return $this->get($this->getPath($id), $params); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Filter cards related to a given list |
|
33
|
|
|
* @link https://trello.com/docs/api/list/#get-1-lists-idlist-cards-filter |
|
34
|
|
|
* |
|
35
|
|
|
* @param string $id the list's id |
|
36
|
|
|
* @param array $filter one of 'none', 'open', 'closed', 'all' |
|
37
|
|
|
* |
|
38
|
|
|
* @return array |
|
39
|
|
|
*/ |
|
40
|
3 |
|
public function filter($id, $filter = 'all') |
|
41
|
|
|
{ |
|
42
|
3 |
|
$allowed = array('none', 'open', 'closed', 'all'); |
|
43
|
3 |
|
$filters = $this->validateAllowedParameters($allowed, $filter, 'filter'); |
|
44
|
|
|
|
|
45
|
3 |
|
return $this->get($this->getPath($id).'/'.implode(',', $filters)); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Create a card |
|
50
|
|
|
* @link https://trello.com/docs/api/list/#post-1-lists-idlist-cards |
|
51
|
|
|
* |
|
52
|
|
|
* @param array $params optional attributes |
|
53
|
|
|
* |
|
54
|
|
|
* @return array card info |
|
55
|
|
|
*/ |
|
56
|
1 |
|
public function create($id, $name, array $params = array()) |
|
57
|
|
|
{ |
|
58
|
1 |
|
$params['idList'] = $id; |
|
59
|
1 |
|
$params['name'] = $name; |
|
60
|
|
|
|
|
61
|
1 |
|
if (!array_key_exists('due', $params)) { |
|
62
|
1 |
|
$params['due'] = null; |
|
63
|
1 |
|
} |
|
64
|
|
|
|
|
65
|
1 |
|
return $this->post($this->getPath($id), $params); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Archive all cards of a given list |
|
70
|
|
|
* @link https://trello.com/docs/api/list/#post-1-lists-idlist-archiveallcards |
|
71
|
|
|
* |
|
72
|
|
|
* @param string $id the list's id |
|
73
|
|
|
* |
|
74
|
|
|
* @return array |
|
75
|
|
|
*/ |
|
76
|
1 |
|
public function archiveAll($id) |
|
77
|
|
|
{ |
|
78
|
1 |
|
return $this->post('lists/'.rawurlencode($id).'/archiveAllCards'); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Move all cards of a given list to another list |
|
83
|
|
|
* @link https://trello.com/docs/api/list/#post-1-lists-idlist-moveallcards |
|
84
|
|
|
* |
|
85
|
|
|
* @param string $id Id of the list to move |
|
86
|
|
|
* @param string $boardId id of the board that the cards should be moved to |
|
87
|
|
|
* @param string $destListId id of the list that the cards should be moved to |
|
88
|
|
|
* |
|
89
|
|
|
* @return array |
|
90
|
|
|
*/ |
|
91
|
1 |
|
public function moveAll($id, $boardId, $destListId) |
|
92
|
|
|
{ |
|
93
|
|
|
$data = array( |
|
94
|
1 |
|
'idBoard' => $boardId, |
|
95
|
1 |
|
'idList' => $destListId, |
|
96
|
1 |
|
); |
|
97
|
|
|
|
|
98
|
1 |
|
return $this->post('lists/'.rawurlencode($id).'/moveAllCards', $data); |
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|