Completed
Push — master ( 79a7c0...e39ede )
by Luca
01:15
created

GroupModel::getGroupUsers()   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
 * 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 Psr\Http\Message\ResponseInterface;
15
16
/**
17
 * Class GroupModel
18
 *
19
 * @package Gnello\Mattermost\Models
20
 */
21
class GroupModel extends AbstractModel
22
{
23
    /**
24
     * @var string
25
     */
26
    private static $endpoint = '/groups';
27
28
    /**
29
     * @param array $requestOptions
30
     * @return ResponseInterface
31
     */
32
    public function getGroups(array $requestOptions = [])
33
    {
34
        return $this->client->get(self::$endpoint, $requestOptions);
35
    }
36
37
    /**
38
     * @param $groupId
39
     * @return ResponseInterface
40
     */
41
    public function getGroup($groupId)
42
    {
43
        return $this->client->get(self::$endpoint . '/' . $groupId);
44
    }
45
46
    /**
47
     * @param       $groupId
48
     * @param array $requestOptions
49
     * @return ResponseInterface
50
     */
51
    public function patchGroup($groupId, array $requestOptions)
52
    {
53
        return $this->client->put(self::$endpoint . '/' . $groupId, $requestOptions);
54
    }
55
56
    /**
57
     * @param $groupId
58
     * @param $teamId
59
     * @return ResponseInterface
60
     */
61
    public function linkTeamToGroup($groupId, $teamId)
62
    {
63
        return $this->client->post(self::$endpoint . '/' . $groupId . TeamModel::$endpoint . '/' . $teamId . '/link');
64
    }
65
66
    /**
67
     * @param $groupId
68
     * @param $teamId
69
     * @return ResponseInterface
70
     */
71
    public function deleteLinkTeamToGroup($groupId, $teamId)
72
    {
73
        return $this->client->delete(self::$endpoint . '/' . $groupId . TeamModel::$endpoint . '/' . $teamId . '/link');
74
    }
75
76
    /**
77
     * @param $groupId
78
     * @param $channelId
79
     * @return ResponseInterface
80
     */
81
    public function linkChannelToGroup($groupId, $channelId)
82
    {
83
        return $this->client->post(self::$endpoint . '/' . $groupId . ChannelModel::$endpoint . '/' . $channelId . '/link');
84
    }
85
86
    /**
87
     * @param $groupId
88
     * @param $channelId
89
     * @return ResponseInterface
90
     */
91
    public function deleteLinkChannelToGroup($groupId, $channelId)
92
    {
93
        return $this->client->delete(self::$endpoint . '/' . $groupId . ChannelModel::$endpoint . '/' . $channelId . '/link');
94
    }
95
96
    /**
97
     * @param $groupId
98
     * @param $teamId
99
     * @return ResponseInterface
100
     */
101
    public function getGroupSyncableFromTeamId($groupId, $teamId)
102
    {
103
        return $this->client->get(self::$endpoint . '/' . $groupId . TeamModel::$endpoint . '/' . $teamId);
104
    }
105
106
    /**
107
     * @param $groupId
108
     * @param $channelId
109
     * @return ResponseInterface
110
     */
111
    public function getGroupSyncableFromChannelId($groupId, $channelId)
112
    {
113
        return $this->client->get(self::$endpoint . '/' . $groupId . ChannelModel::$endpoint . '/' . $channelId);
114
    }
115
116
    /**
117
     * @param $groupId
118
     * @return ResponseInterface
119
     */
120
    public function getGroupTeams($groupId)
121
    {
122
        return $this->client->get(self::$endpoint . '/' . $groupId . TeamModel::$endpoint);
123
    }
124
125
    /**
126
     * @param $groupId
127
     * @return ResponseInterface
128
     */
129
    public function getGroupChannels($groupId)
130
    {
131
        return $this->client->get(self::$endpoint . '/' . $groupId . ChannelModel::$endpoint);
132
    }
133
134
    /**
135
     * @param $groupId
136
     * @param $teamId
137
     * @return ResponseInterface
138
     */
139
    public function patchGroupSyncableAssociateToTeam($groupId, $teamId)
140
    {
141
        return $this->client->put(self::$endpoint . '/' . $groupId . TeamModel::$endpoint . '/' . $teamId . '/patch');
142
    }
143
144
    /**
145
     * @param $groupId
146
     * @param $channelId
147
     * @return ResponseInterface
148
     */
149
    public function patchGroupSyncableAssociateToChannel($groupId, $channelId)
150
    {
151
        return $this->client->put(self::$endpoint . '/' . $groupId . ChannelModel::$endpoint . '/' . $channelId . '/patch');
152
    }
153
154
    /**
155
     * @param $groupId
156
     * @param array $requestOptions
157
     * @return ResponseInterface
158
     */
159
    public function getGroupUsers($groupId, array $requestOptions = [])
160
    {
161
        return $this->client->get(self::$endpoint . '/' . $groupId . '/members', $requestOptions);
162
    }
163
164
    /**
165
     * @param $channelId
166
     * @param array $requestOptions
167
     * @return ResponseInterface
168
     */
169
    public function getChannelGroups($channelId, array $requestOptions = [])
170
    {
171
        return $this->client->get(ChannelModel::$endpoint . '/' . $channelId . '/groups', $requestOptions);
172
    }
173
174
    /**
175
     * @param $teamId
176
     * @param array $requestOptions
177
     * @return ResponseInterface
178
     */
179
    public function getTeamGroups($teamId, array $requestOptions = [])
180
    {
181
        return $this->client->get(TeamModel::$endpoint . '/' . $teamId . '/groups', $requestOptions);
182
    }
183
184
185
}
186