zoom_api/chat_channels.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct ChatChannels {
5 pub client: Client,
6}
7
8impl ChatChannels {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 ChatChannels { client }
12 }
13
14 /**
15 * List user's channels.
16 *
17 * This function performs a `GET` to the `/chat/users/{userId}/channels` endpoint.
18 *
19 * Use this API to list a user's chat channels. For user-level apps, pass [the `me` value](https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#mekeyword) instead of the `userId` parameter.
20 *
21 * Zoom chat [channels](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) allow users to communicate via chat in private or public groups.
22 *
23 * **Scopes:** `chat_channel:read` or `chat_channel:read:admin`<br>**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
24 *
25 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note:</b> This API supports both user-managed apps and account-level apps. However, in an <b>account-level</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>, to list channels of another user in the same Zoom account, the user calling this API must have a <a href="https://support.zoom.us/hc/en-us/articles/115001078646-Using-role-management#:~:text=Each%20user%20in%20a%20Zoom,owner%2C%20administrator%2C%20or%20member.&text=Role%2Dbased%20access%20control%20enables,needs%20to%20view%20or%20edit.">role</a> that has the <b>View</b> or <b>Edit</b> permission for the <b>Chat channels</b> feature.</p>
26 *
27 * **Parameters:**
28 *
29 * * `page_size: i64` -- The number of records returned from a single API call.
30 * * `next_page_token: &str` -- The next page token is used to paginate through large result sets. The expiration period for this token is 15 minutes.
31 * * `user_id: &str` -- Unique identifier of the user.
32 */
33 pub async fn get_channels(
34 &self,
35 user_id: &str,
36 page_size: i64,
37 next_page_token: &str,
38 ) -> ClientResult<crate::Response<Vec<crate::types::Channels>>> {
39 let mut query_args: Vec<(String, String)> = Default::default();
40 if !next_page_token.is_empty() {
41 query_args.push(("next_page_token".to_string(), next_page_token.to_string()));
42 }
43 if page_size > 0 {
44 query_args.push(("page_size".to_string(), page_size.to_string()));
45 }
46 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
47 let url = self.client.url(
48 &format!(
49 "/chat/users/{}/channels?{}",
50 crate::progenitor_support::encode_path(user_id),
51 query_
52 ),
53 None,
54 );
55 let resp: crate::Response<crate::types::GetChannelsResponse> = self
56 .client
57 .get(
58 &url,
59 crate::Message {
60 body: None,
61 content_type: None,
62 },
63 )
64 .await?;
65
66 // Return our response data.
67 Ok(crate::Response::new(
68 resp.status,
69 resp.headers,
70 resp.body.channels.to_vec(),
71 ))
72 }
73 /**
74 * List user's channels.
75 *
76 * This function performs a `GET` to the `/chat/users/{userId}/channels` endpoint.
77 *
78 * As opposed to `get_channels`, this function returns all the pages of the request at once.
79 *
80 * Use this API to list a user's chat channels. For user-level apps, pass [the `me` value](https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#mekeyword) instead of the `userId` parameter.
81 *
82 * Zoom chat [channels](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) allow users to communicate via chat in private or public groups.
83 *
84 * **Scopes:** `chat_channel:read` or `chat_channel:read:admin`<br>**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
85 *
86 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note:</b> This API supports both user-managed apps and account-level apps. However, in an <b>account-level</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>, to list channels of another user in the same Zoom account, the user calling this API must have a <a href="https://support.zoom.us/hc/en-us/articles/115001078646-Using-role-management#:~:text=Each%20user%20in%20a%20Zoom,owner%2C%20administrator%2C%20or%20member.&text=Role%2Dbased%20access%20control%20enables,needs%20to%20view%20or%20edit.">role</a> that has the <b>View</b> or <b>Edit</b> permission for the <b>Chat channels</b> feature.</p>
87 */
88 pub async fn get_all_channels(
89 &self,
90 user_id: &str,
91 ) -> ClientResult<crate::Response<Vec<crate::types::Channels>>> {
92 let url = self.client.url(
93 &format!(
94 "/chat/users/{}/channels",
95 crate::progenitor_support::encode_path(user_id),
96 ),
97 None,
98 );
99 let crate::Response::<crate::types::GetChannelsResponse> {
100 mut status,
101 mut headers,
102 mut body,
103 } = self
104 .client
105 .get(
106 &url,
107 crate::Message {
108 body: None,
109 content_type: None,
110 },
111 )
112 .await?;
113
114 let mut channels = body.channels;
115 let mut page = body.next_page_token;
116
117 // Paginate if we should.
118 while !page.is_empty() {
119 // Check if we already have URL params and need to concat the token.
120 if !url.contains('?') {
121 crate::Response::<crate::types::GetChannelsResponse> {
122 status,
123 headers,
124 body,
125 } = self
126 .client
127 .get(
128 &format!("{}?next_page_token={}", url, page),
129 crate::Message {
130 body: None,
131 content_type: None,
132 },
133 )
134 .await?;
135 } else {
136 crate::Response::<crate::types::GetChannelsResponse> {
137 status,
138 headers,
139 body,
140 } = self
141 .client
142 .get(
143 &format!("{}&next_page_token={}", url, page),
144 crate::Message {
145 body: None,
146 content_type: None,
147 },
148 )
149 .await?;
150 }
151
152 channels.append(&mut body.channels);
153
154 if !body.next_page_token.is_empty() && body.next_page_token != page {
155 page = body.next_page_token.to_string();
156 } else {
157 page = "".to_string();
158 }
159 }
160
161 // Return our response data.
162 Ok(crate::Response::new(status, headers, channels))
163 }
164 /**
165 * Create a channel.
166 *
167 * This function performs a `POST` to the `/chat/users/{userId}/channels` endpoint.
168 *
169 * Use this API to create a channel for a user. For user-level apps, pass [the `me` value](https://marketplace.zoom.us/docs/api-reference/using-zoom-apis#mekeyword) instead of the `userId` parameter.
170 *
171 * Zoom chat channels allow users to communicate via chat in private or public groups.
172 *
173 * **Scopes:** `chat_channel:write` or `chat_channel:write:admin`<br>**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
174 *
175 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note:</b> This API supports both user-managed apps and account-level apps. However, in an <b>account-level</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>, to create a channel on behalf of another user in the same Zoom account, the user calling this API must have a <a href="https://support.zoom.us/hc/en-us/articles/115001078646-Using-role-management#:~:text=Each%20user%20in%20a%20Zoom,owner%2C%20administrator%2C%20or%20member.&text=Role%2Dbased%20access%20control%20enables,needs%20to%20view%20or%20edit.">role</a> that has the <b>Edit</b> permission for the <b>Chat channels</b> feature.</p>
176 *
177 * **Parameters:**
178 *
179 * * `user_id: &str` -- Unique identifier of the user.
180 */
181 pub async fn create_channel(
182 &self,
183 user_id: &str,
184 body: &crate::types::CreateChannelRequest,
185 ) -> ClientResult<crate::Response<crate::types::CreateChannelResponse>> {
186 let url = self.client.url(
187 &format!(
188 "/chat/users/{}/channels",
189 crate::progenitor_support::encode_path(user_id),
190 ),
191 None,
192 );
193 self.client
194 .post(
195 &url,
196 crate::Message {
197 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
198 content_type: Some("application/json".to_string()),
199 },
200 )
201 .await
202 }
203 /**
204 * Get a channel.
205 *
206 * This function performs a `GET` to the `/chat/channels/{channelId}` endpoint.
207 *
208 * Zoom chat [channels](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) allow users to communicate via chat in private or public groups. Use this API to get information about a specific channel.
209 *
210 * **Scope:** `chat_channel:read` <br>
211 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
212 *
213 * <p style="background-color:#e1f5fe; color:#000000; padding:8px"> <b>Note: </b> This API supports only <b>user-managed</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth apps</a>. If you use an Account-Level OAuth Access token, you can only retrieve the channel information for the authorized user. You can't retrieve the channel information of other account users. Use the <a href="https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-channels-account-level/getchannel">Account-Level Get Channel Info API</a> to retrieve the channel information of other account users.</p><br>
214 *
215 *
216 *
217 *
218 * **Parameters:**
219 *
220 * * `channel_id: &str` -- Channel ID: Unique Identifier of a channel.
221 */
222 pub async fn get_user_level_channel(
223 &self,
224 channel_id: &str,
225 ) -> ClientResult<crate::Response<crate::types::Channel>> {
226 let url = self.client.url(
227 &format!(
228 "/chat/channels/{}",
229 crate::progenitor_support::encode_path(channel_id),
230 ),
231 None,
232 );
233 self.client
234 .get(
235 &url,
236 crate::Message {
237 body: None,
238 content_type: None,
239 },
240 )
241 .await
242 }
243 /**
244 * Delete a channel.
245 *
246 * This function performs a `DELETE` to the `/chat/channels/{channelId}` endpoint.
247 *
248 * Zoom chat [channels](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) allow users to communicate via chat in private or public groups. Use this API to delete a specific channel.
249 *
250 * **Scope:** `chat_channel:write`<br>
251 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
252 *
253 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note: </b> This API only supports <b>user-managed</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>.</p><br>
254 *
255 *
256 *
257 *
258 * **Parameters:**
259 *
260 * * `channel_id: &str` -- Channel ID: Unique Identifier of a channel.
261 */
262 pub async fn delete_user_level_channel(
263 &self,
264 channel_id: &str,
265 ) -> ClientResult<crate::Response<()>> {
266 let url = self.client.url(
267 &format!(
268 "/chat/channels/{}",
269 crate::progenitor_support::encode_path(channel_id),
270 ),
271 None,
272 );
273 self.client
274 .delete(
275 &url,
276 crate::Message {
277 body: None,
278 content_type: None,
279 },
280 )
281 .await
282 }
283 /**
284 * Update a channel.
285 *
286 * This function performs a `PATCH` to the `/chat/channels/{channelId}` endpoint.
287 *
288 * Zoom chat channels allow users to communicate via chat in private or public channels. Use this API to update the name of a specific channel that you created.
289 *
290 * **Scope:** `chat_channel:write` <br>
291 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
292 *
293 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note: </b> This API only supports <b>user-managed</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>.</p><br>
294 *
295 *
296 *
297 * **Parameters:**
298 *
299 * * `channel_id: &str` -- User's first name.
300 */
301 pub async fn update_user_level_channel(
302 &self,
303 channel_id: &str,
304 body: &crate::types::Attendees,
305 ) -> ClientResult<crate::Response<()>> {
306 let url = self.client.url(
307 &format!(
308 "/chat/channels/{}",
309 crate::progenitor_support::encode_path(channel_id),
310 ),
311 None,
312 );
313 self.client
314 .patch(
315 &url,
316 crate::Message {
317 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
318 content_type: None,
319 },
320 )
321 .await
322 }
323 /**
324 * Remove a member.
325 *
326 * This function performs a `DELETE` to the `/chat/channels/{channelId}/members/{memberId}` endpoint.
327 *
328 * A [channel](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) can have one or multiple members. Use this API to remove a member from a chat channel.<br><br>
329 * **Scopes:** `chat_channel:write`<br>
330 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
331 *
332 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note: </b> This API only supports <b>user-managed</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>.</p><br>
333 *
334 *
335 *
336 *
337 * **Parameters:**
338 *
339 * * `channel_id: &str` -- Unique Identifier of the Channel from where you would like to remove a member. This can be retrieved from the [List Channels API](https://marketplace.zoom.us/docs/api-reference/zoom-api/chat-channels/getchannels).
340 * * `member_id: &str` -- Email address of the member whom you would like to be remove from the channel.
341 */
342 pub async fn remove_user_level_channel_member(
343 &self,
344 channel_id: &str,
345 member_id: &str,
346 ) -> ClientResult<crate::Response<()>> {
347 let url = self.client.url(
348 &format!(
349 "/chat/channels/{}/members/{}",
350 crate::progenitor_support::encode_path(channel_id),
351 crate::progenitor_support::encode_path(member_id),
352 ),
353 None,
354 );
355 self.client
356 .delete(
357 &url,
358 crate::Message {
359 body: None,
360 content_type: None,
361 },
362 )
363 .await
364 }
365 /**
366 * Join a channel.
367 *
368 * This function performs a `POST` to the `/chat/channels/{channelId}/members/me` endpoint.
369 *
370 * A [channel](https://support.zoom.us/hc/en-us/articles/200912909-Getting-Started-With-Channels-Group-Messaging-) can have one or multiple members. Use this API to join a channel that is open for anyone in the same organization to join. You cannot use this API to join private channels that only allows invited members to be a part of it.
371 *
372 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note: </b>This API only supports <b>user-managed</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>.</p><br>
373 *
374 * **Scope:** `chat_channel:write`<br>
375 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
376 *
377 * **Parameters:**
378 *
379 * * `channel_id: &str` -- User's first name.
380 */
381 pub async fn join_channel(
382 &self,
383 channel_id: &str,
384 ) -> ClientResult<crate::Response<crate::types::JoinChannelResponse>> {
385 let url = self.client.url(
386 &format!(
387 "/chat/channels/{}/members/me",
388 crate::progenitor_support::encode_path(channel_id),
389 ),
390 None,
391 );
392 self.client
393 .post(
394 &url,
395 crate::Message {
396 body: None,
397 content_type: None,
398 },
399 )
400 .await
401 }
402 /**
403 * Leave a channel.
404 *
405 * This function performs a `DELETE` to the `/chat/channels/{channelId}/members/me` endpoint.
406 *
407 * If you're no longer interested in being a member of an existing channel, you can leave the channel at any time. Use this API to leave a specific channel. After leaving the channel, you can no longer access information from that channel.
408 *
409 * <p style="background-color:#e1f5fe; color:#01579b; padding:8px"> <b>Note: </b>This API only supports <b>user-managed</b> <a href="https://marketplace.zoom.us/docs/guides/getting-started/app-types/create-oauth-app">OAuth app</a>.</p><br>
410 *
411 * **Scope:** `chat_channel:write`<br>
412 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
413 *
414 * **Parameters:**
415 *
416 * * `channel_id: &str` -- Channel ID: Unique Identifier of a channel.
417 */
418 pub async fn leave_channel(&self, channel_id: &str) -> ClientResult<crate::Response<()>> {
419 let url = self.client.url(
420 &format!(
421 "/chat/channels/{}/members/me",
422 crate::progenitor_support::encode_path(channel_id),
423 ),
424 None,
425 );
426 self.client
427 .delete(
428 &url,
429 crate::Message {
430 body: None,
431 content_type: None,
432 },
433 )
434 .await
435 }
436}