Completed
Push — master ( 222ae3...326e49 )
by Luca
02:02
created

ChannelModel::getDeletedChannels()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/**
3
 * This Driver is based entirely on official documentation of the Mattermost Web
4
 * Services API and you can extend it by following the directives of the documentation.
5
 *
6
 * For the full copyright and license information, please read the LICENSE.txt
7
 * file that was distributed with this source code. For the full list of
8
 * contributors, visit https://github.com/gnello/php-mattermost-driver/contributors
9
 *
10
 * God bless this mess.
11
 *
12
 * @author Luca Agnello <[email protected]>
13
 * @link https://api.mattermost.com/
14
 */
15
16
namespace Gnello\Mattermost\Models;
17
18
use Psr\Http\Message\ResponseInterface;
19
20
/**
21
 * Class ChannelModel
22
 *
23
 * @package Gnello\Mattermost\Models
24
 */
25
class ChannelModel extends AbstractModel
26
{
27
    /**
28
     * @var string
29
     */
30
    public static $endpoint = '/channels';
31
32
    /**
33
     * @param array $requestOptions
34
     * @return ResponseInterface
35
     */
36
    public function createChannel(array $requestOptions)
37
    {
38
        return $this->client->post(self::$endpoint, $requestOptions);
39
    }
40
41
    /**
42
     * @param array $requestOptions
43
     * @return ResponseInterface
44
     */
45
    public function createDirectMessageChannel(array $requestOptions)
46
    {
47
        return $this->client->post(self::$endpoint . '/direct', $requestOptions);
48
    }
49
50
    /**
51
     * @param array $requestOptions
52
     * @return ResponseInterface
53
     */
54
    public function createGroupMessageChannel(array $requestOptions)
55
    {
56
        return $this->client->post(self::$endpoint . '/group', $requestOptions);
57
    }
58
59
    /**
60
     * @param       $teamId
61
     * @param array $requestOptions
62
     * @return ResponseInterface
63
     */
64
    public function getChannelsListByIds($teamId, array $requestOptions)
65
    {
66
        return $this->client->post(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/ids', $requestOptions);
67
    }
68
69
    /**
70
     * @param $channelId
71
     * @return ResponseInterface
72
     */
73
    public function getChannel($channelId)
74
    {
75
        return $this->client->get(self::$endpoint . '/' . $channelId);
76
    }
77
78
    /**
79
     * @param       $channelId
80
     * @param array $requestOptions
81
     * @return ResponseInterface
82
     */
83
    public function updateChannel($channelId, array $requestOptions)
84
    {
85
        return $this->client->put(self::$endpoint . '/' . $channelId, $requestOptions);
86
    }
87
88
    /**
89
     * @param $channelId
90
     * @return ResponseInterface
91
     */
92
    public function deleteChannel($channelId)
93
    {
94
        return $this->client->delete(self::$endpoint . '/' . $channelId);
95
    }
96
97
    /**
98
     * @param       $channelId
99
     * @param array $requestOptions
100
     * @return ResponseInterface
101
     */
102
    public function patchChannel($channelId, array $requestOptions)
103
    {
104
        return $this->client->put(self::$endpoint . '/' . $channelId . '/patch', $requestOptions);
105
    }
106
107
    /**
108
     * @param       $channelId
109
     * @return ResponseInterface
110
     */
111
    public function restoreChannel($channelId)
112
    {
113
        return $this->client->post(self::$endpoint . '/' . $channelId . '/restore');
114
    }
115
116
    /**
117
     * @param $channelId
118
     * @return ResponseInterface
119
     */
120
    public function getChannelStatistics($channelId)
121
    {
122
        return $this->client->get(self::$endpoint . '/' . $channelId . '/stats');
123
    }
124
125
    /**
126
     * @param $channelId
127
     * @return ResponseInterface
128
     */
129
    public function getChannelsPinnedPosts($channelId)
130
    {
131
        return $this->client->get(self::$endpoint . '/' . $channelId . '/pinned');
132
    }
133
134
    /**
135
     * @param $teamId
136
     * @param $channelName
137
     * @return ResponseInterface
138
     */
139
    public function getChannelByName($teamId, $channelName)
140
    {
141
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/name/' . $channelName);
142
    }
143
144
    /**
145
     * @param $teamName
146
     * @param $channelName
147
     * @return ResponseInterface
148
     */
149
    public function getChannelByNameAndTeamName($teamName, $channelName)
150
    {
151
        return $this->client->get(TeamModel::$endpoint . '/name/' . $teamName . self::$endpoint . '/name/' . $channelName);
152
    }
153
154
    /**
155
     * @param $channelId
156
     * @param array $requestOptions
157
     * @return ResponseInterface
158
     */
159
    public function getChannelMembers($channelId, array $requestOptions)
160
    {
161
        return $this->client->get(self::$endpoint . '/' . $channelId . '/members', $requestOptions);
162
    }
163
164
    /**
165
     * @param       $channelId
166
     * @param array $requestOptions
167
     * @return ResponseInterface
168
     */
169
    public function addUser($channelId, array $requestOptions)
170
    {
171
        return $this->client->post(self::$endpoint . '/' . $channelId . '/members', $requestOptions);
172
    }
173
174
    /**
175
     * @param       $channelId
176
     * @param array $requestOptions
177
     * @return ResponseInterface
178
     */
179
    public function getChannelMembersByIds($channelId, array $requestOptions)
180
    {
181
        return $this->client->post(self::$endpoint . '/' . $channelId . '/members/ids', $requestOptions);
182
    }
183
184
    /**
185
     * @param $channelId
186
     * @param $userId
187
     * @return ResponseInterface
188
     */
189
    public function getChannelMember($channelId, $userId)
190
    {
191
        return $this->client->get(self::$endpoint . '/' . $channelId . '/members/' . $userId);
192
    }
193
194
    /**
195
     * @param $channelId
196
     * @param $userId
197
     * @return ResponseInterface
198
     */
199
    public function removeUserFromChannel($channelId, $userId)
200
    {
201
        return $this->client->delete(self::$endpoint . '/' . $channelId . '/members/' . $userId);
202
    }
203
204
    /**
205
     * @param       $channelId
206
     * @param       $userId
207
     * @param array $requestOptions
208
     * @return ResponseInterface
209
     */
210
    public function updateChannelRoles($channelId, $userId, array $requestOptions)
211
    {
212
        return $this->client->put(self::$endpoint . '/' . $channelId . '/members/' . $userId . '/roles', $requestOptions);
213
    }
214
215
    /**
216
     * @param       $channelId
217
     * @param       $userId
218
     * @param array $requestOptions
219
     * @return ResponseInterface
220
     */
221
    public function updateChannelNotifications($channelId, $userId, array $requestOptions)
222
    {
223
        return $this->client->put(self::$endpoint . '/' . $channelId . '/members/' . $userId . '/notify_props', $requestOptions);
224
    }
225
226
    /**
227
     * @param       $userId
228
     * @param array $requestOptions
229
     * @return ResponseInterface
230
     */
231
    public function viewChannel($userId, array $requestOptions)
232
    {
233
        return $this->client->post(self::$endpoint . '/members/' . $userId . '/view', $requestOptions);
234
    }
235
236
    /**
237
     * @param $userId
238
     * @param $teamId
239
     * @return ResponseInterface
240
     */
241
    public function getChannelMembersForTheUser($userId, $teamId)
242
    {
243
        return $this->client->get(UserModel::$endpoint . '/' . $userId . '/' . TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/members');
244
    }
245
246
    /**
247
     * @param $userId
248
     * @param $teamId
249
     * @return ResponseInterface
250
     */
251
    public function getChannelsForUser($userId, $teamId)
252
    {
253
        return $this->client->get(UserModel::$endpoint . '/' . $userId . '/' . TeamModel::$endpoint . '/' . $teamId . self::$endpoint);
254
    }
255
256
    /**
257
     * @param $userId
258
     * @param $channelId
259
     * @return ResponseInterface
260
     */
261
    public function getUnreadMessages($userId, $channelId)
262
    {
263
        return $this->client->get(UserModel::$endpoint . '/' . $userId . self::$endpoint . '/' . $channelId . '/unread');
264
    }
265
266
    /**
267
     * @param $channelId
268
     * @return ResponseInterface
269
     */
270
    public function convertChannelFromPublicToPrivate($channelId)
271
    {
272
        return $this->client->post(self::$endpoint . '/' . $channelId . '/convert');
273
    }
274
275
    /**
276
     * @param       $teamId
277
     * @param array $requestOptions
278
     * @return ResponseInterface
279
     */
280
    public function getPublicChannels($teamId, array $requestOptions)
281
    {
282
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint, $requestOptions);
283
    }
284
285
    /**
286
     * @param       $teamId
287
     * @param array $requestOptions
288
     * @return ResponseInterface
289
     */
290
    public function getDeletedChannels($teamId, array $requestOptions)
291
    {
292
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/deleted', $requestOptions);
293
    }
294
295
    /**
296
     * @param       $teamId
297
     * @param array $requestOptions
298
     * @return ResponseInterface
299
     */
300
    public function autocompleteChannels($teamId, array $requestOptions)
301
    {
302
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/autocomplete', $requestOptions);
303
    }
304
305
    /**
306
     * @param       $teamId
307
     * @param array $requestOptions
308
     * @return ResponseInterface
309
     */
310
    public function autocompleteChannelsForSearch($teamId, array $requestOptions)
311
    {
312
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/search_autocomplete', $requestOptions);
313
    }
314
315
    /**
316
     * @param       $teamId
317
     * @param array $requestOptions
318
     * @return ResponseInterface
319
     */
320
    public function searchChannels($teamId, array $requestOptions)
321
    {
322
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . self::$endpoint . '/search', $requestOptions);
323
    }
324
}
325