15
15
16
16
namespace Gnello \Mattermost \Models ;
17
17
18
+ use Gnello \Mattermost \Client ;
19
+
18
20
/**
19
21
* Class ChannelModel
20
22
*
@@ -28,12 +30,174 @@ class ChannelModel extends AbstractModel
28
30
public static $ endpoint = '/channels ' ;
29
31
30
32
/**
31
- * @param $teamId
33
+ * @var string
34
+ */
35
+ private $ teamId ;
36
+
37
+ /**
38
+ * ChannelModel constructor.
39
+ *
40
+ * @param Client $client
41
+ * @param $teamID
42
+ */
43
+ public function __construct (Client $ client , $ teamID )
44
+ {
45
+ $ this ->teamId = $ teamID ;
46
+ parent ::__construct ($ client );
47
+ }
48
+
49
+ /**
50
+ * @param array $requestOptions
51
+ * @return \Psr\Http\Message\ResponseInterface
52
+ */
53
+ public function createChannel (array $ requestOptions )
54
+ {
55
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/create ' , $ requestOptions );
56
+ }
57
+
58
+ /**
59
+ * @param array $requestOptions
60
+ * @return \Psr\Http\Message\ResponseInterface
61
+ */
62
+ public function updateChannel (array $ requestOptions )
63
+ {
64
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/update ' , $ requestOptions );
65
+ }
66
+
67
+ /**
68
+ * @param array $requestOptions
69
+ * @return \Psr\Http\Message\ResponseInterface
70
+ */
71
+ public function viewChannel (array $ requestOptions )
72
+ {
73
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/view ' , $ requestOptions );
74
+ }
75
+
76
+ /**
77
+ * @return \Psr\Http\Message\ResponseInterface
78
+ */
79
+ public function getChannelsForTheUser ()
80
+ {
81
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' );
82
+ }
83
+
84
+ /**
85
+ * @param $channelName
86
+ * @return \Psr\Http\Message\ResponseInterface
87
+ */
88
+ public function getChannelByName ($ channelName )
89
+ {
90
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/name/ ' . $ channelName );
91
+ }
92
+
93
+ /**
94
+ * @param $offset
95
+ * @param $limit
96
+ * @return \Psr\Http\Message\ResponseInterface
97
+ */
98
+ public function getPageOfChannelsTheUserHasNotJoined ($ offset , $ limit )
99
+ {
100
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/more/ ' . $ offset . '/ ' . $ limit );
101
+ }
102
+
103
+ /**
104
+ * @return \Psr\Http\Message\ResponseInterface
105
+ */
106
+ public function getChannelMembersForTheUser ()
107
+ {
108
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/members ' );
109
+ }
110
+
111
+ /**
112
+ * @return \Psr\Http\Message\ResponseInterface
113
+ */
114
+ public function getChannelsPinnedPosts ()
115
+ {
116
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/pinned ' );
117
+ }
118
+
119
+ /**
120
+ * @param $channelId
121
+ * @return \Psr\Http\Message\ResponseInterface
122
+ */
123
+ public function getChannel ($ channelId )
124
+ {
125
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId );
126
+ }
127
+
128
+ /**
129
+ * @param $channelId
130
+ * @return \Psr\Http\Message\ResponseInterface
131
+ */
132
+ public function getStatsOfChannel ($ channelId )
133
+ {
134
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId . '/stats ' );
135
+ }
136
+
137
+ /**
138
+ * @param $channelId
139
+ * @return \Psr\Http\Message\ResponseInterface
140
+ */
141
+ public function deleteChannel ($ channelId )
142
+ {
143
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId . '/delete ' );
144
+ }
145
+
146
+ /**
147
+ * @param $channelId
148
+ * @param array $requestOptions
149
+ * @return \Psr\Http\Message\ResponseInterface
150
+ */
151
+ public function addUser ($ channelId , array $ requestOptions )
152
+ {
153
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId . '/add ' , $ requestOptions );
154
+ }
155
+
156
+ /**
157
+ * @param $channelId
158
+ * @param $userId
159
+ * @return \Psr\Http\Message\ResponseInterface
160
+ */
161
+ public function getChannelMember ($ channelId , $ userId )
162
+ {
163
+ return $ this ->client ->get (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId . '/members/ ' . $ userId );
164
+ }
165
+
166
+ /**
167
+ * @param $channelId
168
+ * @param array $requestOptions
169
+ * @return \Psr\Http\Message\ResponseInterface
170
+ */
171
+ public function getChannelMembersByIds ($ channelId , array $ requestOptions )
172
+ {
173
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId . '/members/ids ' , $ requestOptions );
174
+ }
175
+
176
+ /**
177
+ * @param $channelId
178
+ * @param array $requestOptions
179
+ * @return \Psr\Http\Message\ResponseInterface
180
+ */
181
+ public function updateRolesOfChannelMember ($ channelId , array $ requestOptions )
182
+ {
183
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/ ' . $ channelId . '/update_member_roles ' , $ requestOptions );
184
+ }
185
+
186
+ /**
187
+ * @param array $requestOptions
188
+ * @return \Psr\Http\Message\ResponseInterface
189
+ */
190
+ public function autocompleteChannelsInATeam (array $ requestOptions )
191
+ {
192
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this ->teamId . '/ ' . self ::$ endpoint . '/autocomplete ' , $ requestOptions );
193
+ }
194
+
195
+ /**
32
196
* @param array $requestOptions
33
197
* @return \Psr\Http\Message\ResponseInterface
34
198
*/
35
- public function createChannel ( $ teamId , array $ requestOptions )
199
+ public function searchForMoreChannels ( array $ requestOptions )
36
200
{
37
- return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ teamId . '/ ' . self ::$ endpoint . '/create ' , $ requestOptions );
201
+ return $ this ->client ->post (TeamModel::$ endpoint . '/ ' . $ this -> teamId . '/ ' . self ::$ endpoint . '/more/search ' , $ requestOptions );
38
202
}
39
203
}
0 commit comments