Completed
Push — master ( ee4abe...b555bd )
by Luca
10s
created

UserModel::getUserStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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
 * God bless this mess.
7
 *
8
 * @author Luca Agnello <[email protected]>
9
 * @link https://api.mattermost.com/
10
 */
11
12
namespace Gnello\Mattermost\Models;
13
14
use Gnello\Mattermost\Client;
15
16
/**
17
 * Class UserEntity
18
 *
19
 * @package Gnello\MattermostRestApi\Entities
20
 */
21
class UserModel extends AbstractModel
22
{
23
    /**
24
     * @var string
25
     */
26
    public static $endpoint = '/users';
27
28
    /**
29
     * @param array $requestOptions
30
     * @return \Psr\Http\Message\ResponseInterface
31
     */
32
    public function loginToUserAccount(array $requestOptions)
33
    {
34
        return $this->client->post(self::$endpoint . '/login', $requestOptions);
35
    }
36
37
    /**
38
     * @return \Psr\Http\Message\ResponseInterface
39
     */
40
    public function logoutOfUserAccount()
41
    {
42
        return $this->client->post(self::$endpoint . '/logout');
43
    }
44
45
    /**
46
     * @return \Psr\Http\Message\ResponseInterface
47
     */
48
    public function getAuthenticatedUser()
49
    {
50
        return $this->client->get(self::$endpoint . '/me');
51
    }
52
53
    /**
54
     * @param array $requestOptions
55
     * @return \Psr\Http\Message\ResponseInterface
56
     */
57
    public function createUser(array $requestOptions)
58
    {
59
        return $this->client->post(self::$endpoint, $requestOptions);
60
    }
61
62
    /**
63
     * @param array $requestOptions
64
     * @return \Psr\Http\Message\ResponseInterface
65
     */
66
    public function getUsers(array $requestOptions)
67
    {
68
        return $this->client->get(self::$endpoint, $requestOptions);
69
    }
70
71
    /**
72
     * @param $requestOptions
73
     * @return \Psr\Http\Message\ResponseInterface
74
     */
75
    public function getUsersByIds(array $requestOptions)
76
    {
77
        return $this->client->post(self::$endpoint . '/ids', $requestOptions);
78
    }
79
80
    /**
81
     * @param array $requestOptions
82
     * @return \Psr\Http\Message\ResponseInterface
83
     */
84
    public function searchUsers(array $requestOptions)
85
    {
86
        return $this->client->post(self::$endpoint . '/search', $requestOptions);
87
    }
88
89
    /**
90
     * @param array $requestOptions
91
     * @return \Psr\Http\Message\ResponseInterface
92
     */
93
    public function autocompleteUsers(array $requestOptions)
94
    {
95
        return $this->client->get(self::$endpoint . '/autocomplete', $requestOptions);
96
    }
97
98
    /**
99
     * @param $userId
100
     * @return \Psr\Http\Message\ResponseInterface
101
     */
102
    public function getUser($userId)
103
    {
104
        return $this->client->get(self::$endpoint . '/' . $userId);
105
    }
106
107
    /**
108
     * @param $userId
109
     * @param array $requestOptions
110
     * @return \Psr\Http\Message\ResponseInterface
111
     */
112
    public function updateUser($userId, array $requestOptions)
113
    {
114
        return $this->client->put(self::$endpoint . '/' . $userId, $requestOptions);
115
    }
116
117
    /**
118
     * @param $userId
119
     * @return \Psr\Http\Message\ResponseInterface
120
     */
121
    public function deactivateUserAccount($userId)
122
    {
123
        return $this->client->delete(self::$endpoint . '/' . $userId);
124
    }
125
126
    /**
127
     * @param $userId
128
     * @param array $requestOptions
129
     * @return \Psr\Http\Message\ResponseInterface
130
     */
131
    public function patchUser($userId, array $requestOptions)
132
    {
133
        return $this->client->put(self::$endpoint . '/' . $userId . '/patch', $requestOptions);
134
    }
135
136
    /**
137
     * @param $userId
138
     * @param array $requestOptions
139
     * @return \Psr\Http\Message\ResponseInterface
140
     */
141
    public function updateUserRoles($userId, array $requestOptions)
142
    {
143
        return $this->client->put(self::$endpoint . '/' . $userId . '/roles', $requestOptions);
144
    }
145
146
    /**
147
     * @param $userId
148
     * @param array $requestOptions
149
     * @return \Psr\Http\Message\ResponseInterface
150
     */
151
    public function updateUserActive($userId, array $requestOptions)
152
    {
153
        return $this->client->put(self::$endpoint . '/' . $userId . '/active', $requestOptions);
154
    }
155
156
    /**
157
     * @param $userId
158
     * @return \Psr\Http\Message\ResponseInterface
159
     */
160
    public function getUserProfileImage($userId)
161
    {
162
        return $this->client->get(self::$endpoint . '/' . $userId . '/image');
163
    }
164
165
    /**
166
     * @param $userId
167
     * @param array $requestOptions
168
     * @return \Psr\Http\Message\ResponseInterface
169
     */
170
    public function setUserProfileImage($userId, array $requestOptions)
171
    {
172
        return $this->client->post(self::$endpoint . '/' . $userId . '/image', $requestOptions, Client::TYPE_MULTIPART);
173
    }
174
175
    /**
176
     * @param $username
177
     * @return \Psr\Http\Message\ResponseInterface
178
     */
179
    public function getUserByUsername($username)
180
    {
181
        return $this->client->get(self::$endpoint . '/username/' . $username);
182
    }
183
184
    /**
185
     * @param $requestOptions
186
     * @return \Psr\Http\Message\ResponseInterface
187
     */
188
    public function getUsersByUsernames(array $requestOptions)
189
    {
190
        return $this->client->post(self::$endpoint . '/usernames/', $requestOptions);
191
    }
192
193
    /**
194
     * @param $requestOptions
195
     * @return \Psr\Http\Message\ResponseInterface
196
     */
197
    public function resetPassword(array $requestOptions)
198
    {
199
        return $this->client->post(self::$endpoint . '/password/reset', $requestOptions);
200
    }
201
    
202
    /**
203
     * @param $userId
204
     * @param $requestOptions
205
     * @return \Psr\Http\Message\ResponseInterface
206
     */
207
    public function updateUserMfa($userId, array $requestOptions)
208
    {
209
        return $this->client->put(self::$endpoint . '/' . $userId . '/mfa', $requestOptions);
210
    }
211
212
    /**
213
     * @param $userId
214
     * @param $requestOptions
215
     * @return \Psr\Http\Message\ResponseInterface
216
     */
217
    public function generateMfaSecret($userId, array $requestOptions)
218
    {
219
        return $this->client->post(self::$endpoint . '/' . $userId . '/mfa/generate', $requestOptions);
220
    }
221
222
    /**
223
     * @param $requestOptions
224
     * @return \Psr\Http\Message\ResponseInterface
225
     */
226
    public function checkMfa(array $requestOptions)
227
    {
228
        return $this->client->post(self::$endpoint . '/mfa', $requestOptions);
229
    }
230
231
    /**
232
     * @param $userId
233
     * @param $requestOptions
234
     * @return \Psr\Http\Message\ResponseInterface
235
     */
236
    public function updateUserPassword($userId, array $requestOptions)
237
    {
238
        return $this->client->put(self::$endpoint . '/' . $userId . '/password', $requestOptions);
239
    }
240
241
    /**
242
     * @param $requestOptions
243
     * @return \Psr\Http\Message\ResponseInterface
244
     */
245
    public function sendPasswordResetEmail(array $requestOptions)
246
    {
247
        return $this->client->post(self::$endpoint . '/password/reset/send', $requestOptions);
248
    }
249
250
    /**
251
     * @param $email
252
     * @return \Psr\Http\Message\ResponseInterface
253
     */
254
    public function getUserByEmail($email)
255
    {
256
        return $this->client->get(self::$endpoint . '/email/' . $email);
257
    }
258
259
    /**
260
     * @param $userId
261
     * @return \Psr\Http\Message\ResponseInterface
262
     */
263
    public function getUserSessions($userId)
264
    {
265
        return $this->client->get(self::$endpoint . '/' . $userId . '/sessions');
266
    }
267
268
    /**
269
     * @param $userId
270
     * @param array $requestOptions
271
     * @return \Psr\Http\Message\ResponseInterface
272
     */
273
    public function revokeUserSession($userId, array $requestOptions)
274
    {
275
        return $this->client->post(self::$endpoint . '/' . $userId . '/sessions/revoke', $requestOptions);
276
    }
277
278
    /**
279
     * @param $userId
280
     * @return \Psr\Http\Message\ResponseInterface
281
     */
282
    public function revokeAllUserSessions($userId)
283
    {
284
        return $this->client->post(self::$endpoint . '/' . $userId . '/sessions/revoke/all');
285
    }
286
287
    /**
288
     * @param $requestOptions
289
     * @return \Psr\Http\Message\ResponseInterface
290
     */
291
    public function attachMobileDevice(array $requestOptions)
292
    {
293
        return $this->client->put(self::$endpoint . '/sessions/device', $requestOptions);
294
    }
295
296
    /**
297
     * @param $userId
298
     * @return \Psr\Http\Message\ResponseInterface
299
     */
300
    public function getUserAudits($userId)
301
    {
302
        return $this->client->get(self::$endpoint . '/' . $userId . '/audits');
303
    }
304
305
    /**
306
     * @param array $requestOptions
307
     * @return \Psr\Http\Message\ResponseInterface
308
     */
309
    public function verifyUserEmail(array $requestOptions)
310
    {
311
        return $this->client->post(self::$endpoint . '/email/verify', $requestOptions);
312
    }
313
314
    /**
315
     * @param array $requestOptions
316
     * @return \Psr\Http\Message\ResponseInterface
317
     */
318
    public function sendVerificationEmail(array $requestOptions)
319
    {
320
        return $this->client->post(self::$endpoint . '/email/verify/send', $requestOptions);
321
    }
322
323
    /**
324
     * @param array $requestOptions
325
     * @return \Psr\Http\Message\ResponseInterface
326
     */
327
    public function switchLoginMethod(array $requestOptions)
328
    {
329
        return $this->client->post(self::$endpoint . '/login/switch', $requestOptions);
330
    }
331
332
    /**
333
     * @param $userId
334
     * @param $requestOptions
335
     * @return \Psr\Http\Message\ResponseInterface
336
     */
337
    public function createToken($userId, array $requestOptions)
338
    {
339
        return $this->client->post(self::$endpoint . '/' . $userId . '/tokens', $requestOptions);
340
    }
341
342
    /**
343
     * @param $userId
344
     * @param $requestOptions
345
     * @return \Psr\Http\Message\ResponseInterface
346
     */
347
    public function getTokens($userId, array $requestOptions)
348
    {
349
        return $this->client->get(self::$endpoint . '/' . $userId . '/tokens', $requestOptions);
350
    }
351
352
    /**
353
     * @param $tokenId
354
     * @return \Psr\Http\Message\ResponseInterface
355
     */
356
    public function getToken($tokenId)
357
    {
358
        return $this->client->get(self::$endpoint . '/tokens/' . $tokenId);
359
    }
360
361
    /**
362
     * @param $requestOptions
363
     * @return \Psr\Http\Message\ResponseInterface
364
     */
365
    public function revokeToken(array $requestOptions)
366
    {
367
        return $this->client->post(self::$endpoint . '/tokens/revoke', $requestOptions);
368
    }
369
    
370
    /**
371
     * @param $userId
372
     * @return \Psr\Http\Message\ResponseInterface
373
     */
374
    public function getUserStatus($userId)
375
    {
376
        return $this->client->get(self::$endpoint . '/' . $userId . '/status');
377
    }
378
379
    /**
380
     * @param $userId
381
     * @param $requestOptions
382
     * @return \Psr\Http\Message\ResponseInterface
383
     */
384
    public function updateUserStatus($userId, array $requestOptions)
385
    {
386
        return $this->client->put(self::$endpoint . '/' . $userId . '/status', $requestOptions);
387
    }
388
389
}
390