Notification   A
last analyzed

Complexity

Total Complexity 17

Size/Duplication

Total Lines 280
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 17
lcom 1
cbo 6
dl 0
loc 280
ccs 40
cts 40
cp 1
rs 10
c 0
b 0
f 0

17 Methods

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