Completed
Push — master ( 9433dd...4e40fa )
by Luca
01:15
created

TeamModel::inviteGuestsByEmail()   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 GuzzleHttp\RequestOptions;
19
use Psr\Http\Message\ResponseInterface;
20
21
/**
22
 * Class TeamModel
23
 *
24
 * @package Gnello\Mattermost
25
 */
26
class TeamModel extends AbstractModel
27
{
28
    /**
29
     * @var string
30
     */
31
    public static $endpoint = '/teams';
32
33
    /**
34
     * @param array $requestOptions
35
     * @return ResponseInterface
36
     */
37
    public function createTeam(array $requestOptions)
38
    {
39
        return $this->client->post(self::$endpoint, $requestOptions);
40
    }
41
42
    /**
43
     * @param array $requestOptions
44
     * @return ResponseInterface
45
     */
46
    public function getTeams(array $requestOptions)
47
    {
48
        return $this->client->get(self::$endpoint, $requestOptions);
49
    }
50
51
    /**
52
     * @param $teamId
53
     * @return ResponseInterface
54
     */
55
    public function getTeam($teamId)
56
    {
57
        return $this->client->get(self::$endpoint . '/' . $teamId);
58
    }
59
60
    /**
61
     * @param $teamId
62
     * @param array $requestOptions
63
     * @return ResponseInterface
64
     */
65
    public function updateTeam($teamId, array $requestOptions)
66
    {
67
        return $this->client->put(self::$endpoint . '/' . $teamId, $requestOptions);
68
    }
69
70
    /**
71
     * @param $teamId
72
     * @return ResponseInterface
73
     */
74
    public function deleteTeam($teamId)
75
    {
76
        return $this->client->delete(self::$endpoint . '/' . $teamId);
77
    }
78
79
    /**
80
     * @param $teamId
81
     * @param array $requestOptions
82
     * @return ResponseInterface
83
     */
84
    public function patchTeam($teamId, array $requestOptions)
85
    {
86
        return $this->client->put(self::$endpoint . '/' . $teamId . '/patch', $requestOptions);
87
    }
88
89
    /**
90
     * @param $teamName
91
     * @return ResponseInterface
92
     */
93
    public function getTeamByName($teamName)
94
    {
95
        return $this->client->get(self::$endpoint . '/name/' . $teamName);
96
    }
97
98
    /**
99
     * @param array $requestOptions
100
     * @return ResponseInterface
101
     */
102
    public function searchTeams(array $requestOptions)
103
    {
104
        return $this->client->post(self::$endpoint . '/search', $requestOptions);
105
    }
106
107
    /**
108
     * @param $teamName
109
     * @return ResponseInterface
110
     */
111
    public function checkTeamExists($teamName)
112
    {
113
        return $this->client->get(self::$endpoint . '/name/' . $teamName . '/exists');
114
    }
115
116
    /**
117
     * @param $userId
118
     * @return ResponseInterface
119
     */
120
    public function getUserTeams($userId)
121
    {
122
        return $this->client->get(UserModel::$endpoint . '/' . $userId . '/teams');
123
    }
124
125
    /**
126
     * @param $teamId
127
     * @param array $requestOptions
128
     * @return ResponseInterface
129
     */
130
    public function getTeamMembers($teamId, array $requestOptions)
131
    {
132
        return $this->client->get(self::$endpoint . '/' . $teamId . '/members', $requestOptions);
133
    }
134
135
    /**
136
     * @param $teamId
137
     * @param array $requestOptions
138
     * @return ResponseInterface
139
     */
140
    public function addUser($teamId, array $requestOptions)
141
    {
142
        return $this->client->post(self::$endpoint . '/' . $teamId . '/members', $requestOptions);
143
    }
144
145
    /**
146
     * @param array $requestOptions
147
     * @return ResponseInterface
148
     */
149
    public function addUserFromInvite(array $requestOptions)
150
    {
151
        return $this->client->get(self::$endpoint . '/members/invite', $requestOptions);
152
    }
153
154
    /**
155
     * @param $teamId
156
     * @param array $requestOptions
157
     * @return ResponseInterface
158
     */
159
    public function addMultipleUsers($teamId, array $requestOptions)
160
    {
161
        return $this->client->post(self::$endpoint . '/' . $teamId . '/members/batch', $requestOptions);
162
    }
163
164
    /**
165
     * @param $userId
166
     * @param array $requestOptions
167
     * @return ResponseInterface
168
     */
169
    public function getTeamMembersForUser($userId, array $requestOptions)
170
    {
171
        return $this->client->get(UserModel::$endpoint . '/' . $userId . '/teams/members', $requestOptions);
172
    }
173
174
    /**
175
     * @param $teamId
176
     * @param $userId
177
     * @return ResponseInterface
178
     */
179
    public function getTeamMember($teamId, $userId)
180
    {
181
        return $this->client->get(self::$endpoint . '/' . $teamId . '/members/' . $userId);
182
    }
183
184
    /**
185
     * @param       $teamId
186
     * @param       $userId
187
     * @param array $requestOptions
188
     * @return ResponseInterface
189
     */
190
    public function removeUser($teamId, $userId, array $requestOptions)
191
    {
192
        return $this->client->delete(self::$endpoint . '/' . $teamId . '/members/' . $userId, $requestOptions);
193
    }
194
195
    /**
196
     * @param       $teamId
197
     * @param array $requestOptions
198
     * @return ResponseInterface
199
     */
200
    public function getTeamMembersByIds($teamId, array $requestOptions)
201
    {
202
        return $this->client->post(self::$endpoint . '/' . $teamId . '/members/ids', $requestOptions);
203
    }
204
205
    /**
206
     * @param $teamId
207
     * @return ResponseInterface
208
     */
209
    public function getTeamStats($teamId)
210
    {
211
        return $this->client->get(self::$endpoint . '/' . $teamId . '/stats');
212
    }
213
214
    /**
215
     * @param $teamId
216
     * @param $userId
217
     * @param array $requestOptions
218
     * @return ResponseInterface
219
     */
220
    public function updateTeamMemberRoles($teamId, $userId, array $requestOptions)
221
    {
222
        return $this->client->get(self::$endpoint . '/' . $teamId . '/members/' . $userId . '/roles', $requestOptions);
223
    }
224
225
    /**
226
     * @param $userId
227
     * @return ResponseInterface
228
     */
229
    public function getUserTotalUnreadMessagesFromTeams($userId)
230
    {
231
        return $this->client->get(UserModel::$endpoint . '/' . $userId . '/teams/unread');
232
    }
233
234
    /**
235
     * @param $userId
236
     * @param $teamId
237
     * @return ResponseInterface
238
     */
239
    public function getUserTotalUnreadMessagesFromTeam($userId, $teamId)
240
    {
241
        return $this->client->get(UserModel::$endpoint . '/' . $userId . '/teams/' . $teamId . '/unread');
242
    }
243
244
    /**
245
     * @param       $teamId
246
     * @param array $requestOptions
247
     * @return ResponseInterface
248
     */
249
    public function inviteUsersByEmail($teamId, array $requestOptions)
250
    {
251
        return $this->client->post(self::$endpoint . '/' . $teamId . '/invite/email', $requestOptions);
252
    }
253
254
    /**
255
     * @param       $teamId
256
     * @param array $requestOptions
257
     * @return ResponseInterface
258
     */
259
    public function inviteGuestsByEmail($teamId, array $requestOptions)
260
    {
261
        return $this->client->post(self::$endpoint . '/' . $teamId . '/invite-guests/email', $requestOptions);
262
    }
263
264
    /**
265
     * @param       $teamId
266
     * @param array $requestOptions
267
     * @return ResponseInterface
268
     */
269
    public function importTeamFromOtherApplication($teamId, array $requestOptions)
270
    {
271
        $internalRequestOptions = self::buildMultipartDataOptions($requestOptions, ['file', 'filesize', 'importFrom']);
272
273
        return $this->client->post(self::$endpoint . '/' . $teamId . '/import', $internalRequestOptions, RequestOptions::MULTIPART);
274
    }
275
276
    /**
277
     * @param $teamId
278
     * @return ResponseInterface
279
     */
280
    public function getInviteInfoForTeam($teamId)
281
    {
282
        return $this->client->get(self::$endpoint . '/invite/' . $teamId);
283
    }
284
285
    /**
286
     * @param $teamId
287
     * @param array $requestOptions
288
     * @return ResponseInterface
289
     */
290
    public function getPublicChannels($teamId, array $requestOptions)
291
    {
292
        return $this->client->get(self::$endpoint . '/' . $teamId . '/channels', $requestOptions);
293
    }
294
295
    /**
296
     * @param $teamId
297
     * @param array $requestOptions
298
     * @return ResponseInterface
299
     */
300
    public function getDeletedChannels($teamId, array $requestOptions)
301
    {
302
        return $this->client->get(self::$endpoint . '/' . $teamId . '/channels/deleted', $requestOptions);
303
    }
304
305
    /**
306
     * @param       $teamId
307
     * @param array $requestOptions
308
     * @return ResponseInterface
309
     */
310
    public function searchChannels($teamId, array $requestOptions)
311
    {
312
        return $this->client->post(self::$endpoint . '/' . $teamId . '/channels/search', $requestOptions);
313
    }
314
}
315