1 | <?php declare(strict_types=1); |
||
47 | class Rooms extends AbstractResource implements \IteratorAggregate |
||
48 | { |
||
49 | const GITHUB_ORG = 'ORG'; |
||
50 | const ORG_CHANNEL = 'ORG_CHANNEL'; |
||
51 | |||
52 | const GITHUB_REPO = 'REPO'; |
||
53 | const REPO_CHANNEL = 'REPO_CHANNEL'; |
||
54 | |||
55 | const ONE_TO_ONE = 'ONETOONE'; |
||
56 | const USER_CHANNEL = 'USER_CHANNEL'; |
||
57 | |||
58 | /** |
||
59 | * List rooms the current user is in |
||
60 | * |
||
61 | * @param string $query Search query |
||
62 | * @return array |
||
63 | * @throws \RuntimeException |
||
64 | * @throws \InvalidArgumentException |
||
65 | */ |
||
66 | public function all(string $query = null): array |
||
74 | |||
75 | /** |
||
76 | * To join a room you'll need to provide a URI for it. |
||
77 | * Said URI can represent a GitHub Org, a GitHub Repo or a Gitter Channel. |
||
78 | * - If the room exists and the user has enough permission to access it, it'll be added to the room. |
||
79 | * - If the room doesn't exist but the supplied URI represents a GitHub Org or GitHub Repo the user |
||
80 | * is an admin of, the room will be created automatically and the user added. |
||
81 | * |
||
82 | * @param string $roomId Required ID of the room you would like to join |
||
83 | * @param string $userId Required ID of the user |
||
84 | * @return array |
||
85 | * @throws \RuntimeException |
||
86 | * @throws \InvalidArgumentException |
||
87 | */ |
||
88 | public function joinUser(string $roomId, string $userId): array |
||
95 | |||
96 | /** |
||
97 | * Join to target room |
||
98 | * |
||
99 | * @param string $roomId Required ID of the room you would like to join |
||
100 | * @return array |
||
101 | * @throws \RuntimeException |
||
102 | * @throws \InvalidArgumentException |
||
103 | */ |
||
104 | public function join(string $roomId): array |
||
108 | |||
109 | /** |
||
110 | * To join a room you'll need to provide a URI for it. |
||
111 | * |
||
112 | * Said URI can represent a GitHub Org, a GitHub Repo or a Gitter Channel. |
||
113 | * - If the room exists and the user has enough permission to access it, it'll be added to the room. |
||
114 | * - If the room doesn't exist but the supplied URI represents a GitHub Org or GitHub Repo the user |
||
115 | * |
||
116 | * is an admin of, the room will be created automatically and the user added. |
||
117 | * |
||
118 | * @param string $name Required URI of the room you would like to join |
||
119 | * @return array |
||
120 | * @throws \RuntimeException |
||
121 | * @throws \InvalidArgumentException |
||
122 | */ |
||
123 | public function joinByName(string $name): array |
||
127 | |||
128 | /** |
||
129 | * @param string $name |
||
130 | * @return array |
||
131 | * @throws \RuntimeException |
||
132 | * @throws \InvalidArgumentException |
||
133 | */ |
||
134 | public function findByName(string $name): array |
||
138 | |||
139 | /** |
||
140 | * Kick target user from target room |
||
141 | * |
||
142 | * @param string $roomId Required ID of the room |
||
143 | * @param string $userId Required ID of the user |
||
144 | * @return array |
||
145 | * @throws \RuntimeException |
||
146 | * @throws \InvalidArgumentException |
||
147 | */ |
||
148 | public function kick(string $roomId, string $userId): array |
||
156 | |||
157 | /** |
||
158 | * This can be self-inflicted to leave the the room and remove room from your left menu. |
||
159 | * |
||
160 | * @param string $roomId Required ID of the room |
||
161 | * @return array |
||
162 | * @throws \RuntimeException |
||
163 | * @throws \InvalidArgumentException |
||
164 | */ |
||
165 | public function leave(string $roomId): array |
||
169 | |||
170 | /** |
||
171 | * Sets up a new topic of target room |
||
172 | * |
||
173 | * @param string $roomId Room id |
||
174 | * @param string $topic Room topic |
||
175 | * @return mixed |
||
176 | * @throws \RuntimeException |
||
177 | * @throws \InvalidArgumentException |
||
178 | */ |
||
179 | public function topic(string $roomId, string $topic): array |
||
187 | |||
188 | /** |
||
189 | * Sets the room is indexed by search engines |
||
190 | * |
||
191 | * @param string $roomId Room id |
||
192 | * @param bool $enabled Enable or disable room indexing |
||
193 | * @return array |
||
194 | * @throws \RuntimeException |
||
195 | * @throws \InvalidArgumentException |
||
196 | */ |
||
197 | public function searchIndex(string $roomId, bool $enabled = true): array |
||
205 | |||
206 | /** |
||
207 | * Sets the tags that define the room |
||
208 | * |
||
209 | * @param string $roomId Room id |
||
210 | * @param array $tags Target tags |
||
211 | * @return array |
||
212 | * @throws \RuntimeException |
||
213 | * @throws \InvalidArgumentException |
||
214 | * |
||
215 | */ |
||
216 | public function tags(string $roomId, array $tags = []): array |
||
224 | |||
225 | /** |
||
226 | * If you hate one of the rooms - you can destroy it! |
||
227 | * Fatality. |
||
228 | * |
||
229 | * @internal BE CAREFUL: THIS IS VERY DANGEROUS OPERATION. |
||
230 | * |
||
231 | * @param string $roomId Target room id |
||
232 | * @return array |
||
233 | * @throws \RuntimeException |
||
234 | * @throws \InvalidArgumentException |
||
235 | */ |
||
236 | public function delete(string $roomId): array |
||
243 | |||
244 | /** |
||
245 | * List of Users currently in the room. |
||
246 | * |
||
247 | * @param string $roomId Target room id |
||
248 | * @param string $query Optional query for users search |
||
249 | * @return \Generator |
||
250 | * @throws \RuntimeException |
||
251 | * @throws \InvalidArgumentException |
||
252 | */ |
||
253 | public function users(string $roomId, string $query = null): \Generator |
||
274 | |||
275 | /** |
||
276 | * Use the streaming API to listen events. |
||
277 | * The streaming API allows real-time access to messages fetching. |
||
278 | * |
||
279 | * @param string $roomId |
||
280 | * @return Observer |
||
281 | * @throws \InvalidArgumentException |
||
282 | */ |
||
283 | public function events(string $roomId): Observer |
||
291 | |||
292 | /** |
||
293 | * Use the streaming API to listen messages. |
||
294 | * The streaming API allows real-time access to messages fetching. |
||
295 | * |
||
296 | * @param string $roomId |
||
297 | * @return Observer |
||
298 | * @throws \InvalidArgumentException |
||
299 | */ |
||
300 | public function messages(string $roomId): Observer |
||
308 | |||
309 | /** |
||
310 | * @return \Generator |
||
311 | * @throws \RuntimeException |
||
312 | * @throws \InvalidArgumentException |
||
313 | */ |
||
314 | public function getIterator(): \Generator |
||
322 | } |
||
323 |