Action::getCard()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Trello\Api;
4
5
use Trello\Exception\InvalidArgumentException;
6
7
/**
8
 * Trello Action API
9
 * @link https://trello.com/docs/api/action
10
 *
11
 * Fully implemented.
12
 */
13
class Action extends AbstractApi
14
{
15
    /**
16
     * Base path of actions api
17
     * @var string
18
     */
19
    protected $path = 'actions';
20
21
    /**
22
     * Action fields
23
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-field
24
     * @var array
25
     */
26
    public static $fields = array(
27
        'idMemberCreator',
28
        'data',
29
        'type',
30
        'date'
31
    );
32
33
    /**
34
     * Find an action by id
35
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction
36
     *
37
     * @param string $id     the action's id
38
     * @param array  $params optional attributes
39
     *
40
     * @return array
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
     * Update a checklist
49
     * @link https://trello.com/docs/api/checklist/#put-1-checklists-idchecklist
50
     *
51
     * @param string $id     the list's id
52
     * @param array  $params list attributes to update
53
     *
54
     * @return array list info
55
     */
56 1
    public function update($id, array $params = array())
57
    {
58 1
        return $this->put($this->getPath().'/'.rawurlencode($id), $params);
59
    }
60
61
    /**
62
     * Remove a action
63
     * @link https://trello.com/docs/api/action/#delete-1-actions-idaction
64
     *
65
     * @param string $id the action's id
66
     *
67
     * @return array
68
     */
69 1
    public function remove($id)
70
    {
71 1
        return $this->delete($this->getPath().'/'.rawurlencode($id));
72
    }
73
74
    /**
75
     * Get an action's board
76
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-board
77
     *
78
     * @param string $id     the action's id
79
     * @param array  $params optional parameters
80
     *
81
     * @return array
82
     */
83 1
    public function getBoard($id, array $params = array())
84
    {
85 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/board', $params);
86
    }
87
88
    /**
89
     * Get the field of a board of a given card
90
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-board
91
     *
92
     * @param string $id    the action's id
93
     * @param array  $field the name of the field
94
     *
95
     * @return array
96
     *
97
     * @throws InvalidArgumentException if the field does not exist
98
     */
99 2
    public function getBoardField($id, $field)
100
    {
101 2
        $this->validateAllowedParameters(Board::$fields, $field, 'field');
102
103 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/board/'.rawurlencode($field));
104
    }
105
106
    /**
107
     * Get an action's list
108
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-list
109
     *
110
     * @param string $id     the action's id
111
     * @param array  $params optional parameters
112
     *
113
     * @return array
114
     */
115 1
    public function getList($id, array $params = array())
116
    {
117 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/list', $params);
118
    }
119
120
    /**
121
     * Get the field of a list of a given action
122
     * @link https://trello.com/docs/api/action/index.html#get-1-actions-idaction-list-field
123
     *
124
     * @param string $id    the action's id
125
     * @param array  $field the name of the field
126
     *
127
     * @return array
128
     *
129
     * @throws InvalidArgumentException if the field does not exist
130
     */
131 2
    public function getListField($id, $field)
132
    {
133 2
        $this->validateAllowedParameters(Cardlist::$fields, $field, 'field');
134
135 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/list/'.rawurlencode($field));
136
    }
137
138
    /**
139
     * Get an action's card
140
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-card
141
     *
142
     * @param string $id     the action's id
143
     * @param array  $params optional parameters
144
     *
145
     * @return array
146
     */
147 1
    public function getCard($id, array $params = array())
148
    {
149 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/card', $params);
150
    }
151
152
    /**
153
     * Get the field of a card of a given action
154
     * @link https://trello.com/docs/api/action/index.html#get-1-actions-idaction-card-field
155
     *
156
     * @param string $id    the action's id
157
     * @param array  $field the name of the field
158
     *
159
     * @return array
160
     *
161
     * @throws InvalidArgumentException if the field does not exist
162
     */
163 2
    public function getCardField($id, $field)
164
    {
165 2
        $this->validateAllowedParameters(Card::$fields, $field, 'field');
166
167 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/card/'.rawurlencode($field));
168
    }
169
170
    /**
171
     * Get an action's member
172
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-member
173
     *
174
     * @param string $id     the action's id
175
     * @param array  $params optional parameters
176
     *
177
     * @return array
178
     */
179 1
    public function getMember($id, array $params = array())
180
    {
181 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/member', $params);
182
    }
183
184
    /**
185
     * Get the field of a member of a given action
186
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-member-field
187
     *
188
     * @param string $id    the action's id
189
     * @param array  $field the name of the field
190
     *
191
     * @return array
192
     *
193
     * @throws InvalidArgumentException if the field does not exist
194
     */
195 2
    public function getMemberField($id, $field)
196
    {
197 2
        $this->validateAllowedParameters(Member::$fields, $field, 'field');
198
199 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/member/'.rawurlencode($field));
200
    }
201
202
    /**
203
     * Get an action's creator
204
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-creator
205
     *
206
     * @param string $id     the action's id
207
     * @param array  $params optional parameters
208
     *
209
     * @return array
210
     */
211 1
    public function getCreator($id, array $params = array())
212
    {
213 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/memberCreator', $params);
214
    }
215
216
    /**
217
     * Get the field of a creator of a given action
218
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-creator-field
219
     *
220
     * @param string $id    the action's id
221
     * @param array  $field the name of the field
222
     *
223
     * @return array
224
     *
225
     * @throws InvalidArgumentException if the field does not exist
226
     */
227 2
    public function getCreatorField($id, $field)
228
    {
229 2
        $this->validateAllowedParameters(Member::$fields, $field, 'field');
230
231 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/memberCreator/'.rawurlencode($field));
232
    }
233
234
    /**
235
     * Get an action's organization
236
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-organization
237
     *
238
     * @param string $id     the action's id
239
     * @param array  $params optional parameters
240
     *
241
     * @return array
242
     */
243 1
    public function getOrganization($id, array $params = array())
244
    {
245 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/organization', $params);
246
    }
247
248
    /**
249
     * Get the field of an organization of a given action
250
     * @link https://trello.com/docs/api/action/#get-1-actions-idaction-organization-field
251
     *
252
     * @param string $id    the action's id
253
     * @param array  $field the name of the field
254
     *
255
     * @return array
256
     *
257
     * @throws InvalidArgumentException if the field does not exist
258
     */
259 2
    public function getOrganizationField($id, $field)
260
    {
261 2
        $this->validateAllowedParameters(Organization::$fields, $field, 'field');
262
263 1
        return $this->get($this->getPath().'/'.rawurlencode($id).'/organization/'.rawurlencode($field));
264
    }
265
266
    /**
267
     * Set a given action's text
268
     * @link https://trello.com/docs/api/action/#put-1-actions-idaction-text
269
     *
270
     * @param string $id   the card's id or short link
271
     * @param string $text the text
272
     *
273
     * @return array card info
274
     */
275 1
    public function setText($id, $text)
276
    {
277 1
        return $this->put($this->getPath().'/'.rawurlencode($id).'/text', array('value' => $text));
278
    }
279
}
280