zoom_api/phone_shared_line_groups.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct PhoneSharedLineGroups {
5 pub client: Client,
6}
7
8impl PhoneSharedLineGroups {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 PhoneSharedLineGroups { client }
12 }
13
14 /**
15 * List shared line groups.
16 *
17 * This function performs a `GET` to the `/phone/shared_line_groups` endpoint.
18 *
19 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. This gives members of the shared line group access to the group's direct phone number and voicemail. Use this API to list all the Shared Line Groups.
20 *
21 * **Prerequisties:** <br>
22 * * Pro or higher account with Zoom Phone license.
23 * * Account owner or admin privileges <br>
24 *
25 * **Scopes:** `phone:read:admin`, `phone:write:admin`
26 *
27 *
28 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
29 *
30 * **Parameters:**
31 *
32 * * `page_size: i64` -- The number of records returned within a single API call.
33 * * `next_page_token: &str` -- The next page token is used to paginate through large result sets. A next page token will be returned whenever the set of available results exceeds the current page size. The expiration period for this token is 15 minutes.
34 */
35 pub async fn list_shared_line_groups(
36 &self,
37 page_size: i64,
38 next_page_token: &str,
39 ) -> ClientResult<crate::Response<Vec<crate::types::SharedLineGroups>>> {
40 let mut query_args: Vec<(String, String)> = Default::default();
41 if !next_page_token.is_empty() {
42 query_args.push(("next_page_token".to_string(), next_page_token.to_string()));
43 }
44 if page_size > 0 {
45 query_args.push(("page_size".to_string(), page_size.to_string()));
46 }
47 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
48 let url = self
49 .client
50 .url(&format!("/phone/shared_line_groups?{}", query_), None);
51 let resp: crate::Response<crate::types::ListSharedLineGroupsResponse> = self
52 .client
53 .get(
54 &url,
55 crate::Message {
56 body: None,
57 content_type: None,
58 },
59 )
60 .await?;
61
62 // Return our response data.
63 Ok(crate::Response::new(
64 resp.status,
65 resp.headers,
66 resp.body.shared_line_groups.to_vec(),
67 ))
68 }
69 /**
70 * List shared line groups.
71 *
72 * This function performs a `GET` to the `/phone/shared_line_groups` endpoint.
73 *
74 * As opposed to `list_shared_line_groups`, this function returns all the pages of the request at once.
75 *
76 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. This gives members of the shared line group access to the group's direct phone number and voicemail. Use this API to list all the Shared Line Groups.
77 *
78 * **Prerequisties:** <br>
79 * * Pro or higher account with Zoom Phone license.
80 * * Account owner or admin privileges <br>
81 *
82 * **Scopes:** `phone:read:admin`, `phone:write:admin`
83 *
84 *
85 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
86 */
87 pub async fn list_all_shared_line_groups(
88 &self,
89 ) -> ClientResult<crate::Response<Vec<crate::types::SharedLineGroups>>> {
90 let url = self.client.url("/phone/shared_line_groups", None);
91 let crate::Response::<crate::types::ListSharedLineGroupsResponse> {
92 mut status,
93 mut headers,
94 mut body,
95 } = self
96 .client
97 .get(
98 &url,
99 crate::Message {
100 body: None,
101 content_type: None,
102 },
103 )
104 .await?;
105
106 let mut shared_line_groups = body.shared_line_groups;
107 let mut page = body.next_page_token;
108
109 // Paginate if we should.
110 while !page.is_empty() {
111 // Check if we already have URL params and need to concat the token.
112 if !url.contains('?') {
113 crate::Response::<crate::types::ListSharedLineGroupsResponse> {
114 status,
115 headers,
116 body,
117 } = self
118 .client
119 .get(
120 &format!("{}?next_page_token={}", url, page),
121 crate::Message {
122 body: None,
123 content_type: None,
124 },
125 )
126 .await?;
127 } else {
128 crate::Response::<crate::types::ListSharedLineGroupsResponse> {
129 status,
130 headers,
131 body,
132 } = self
133 .client
134 .get(
135 &format!("{}&next_page_token={}", url, page),
136 crate::Message {
137 body: None,
138 content_type: None,
139 },
140 )
141 .await?;
142 }
143
144 shared_line_groups.append(&mut body.shared_line_groups);
145
146 if !body.next_page_token.is_empty() && body.next_page_token != page {
147 page = body.next_page_token.to_string();
148 } else {
149 page = "".to_string();
150 }
151 }
152
153 // Return our response data.
154 Ok(crate::Response::new(status, headers, shared_line_groups))
155 }
156 /**
157 * Create a shared line group.
158 *
159 * This function performs a `POST` to the `/phone/shared_line_groups` endpoint.
160 *
161 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. This gives members of the shared line group access to the group's direct phone number and voicemail. Use this API to create a shared line group.
162 *
163 * **Prerequisties:** <br>
164 * * Pro or higher account with Zoom Phone license.
165 * * Account owner or admin privileges
166 *
167 * **Scopes:** `phone:write:admin`
168 *
169 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
170 */
171 pub async fn create_shared_line_group(
172 &self,
173 body: &crate::types::CreateSharedLineGroupRequest,
174 ) -> ClientResult<crate::Response<()>> {
175 let url = self.client.url("/phone/shared_line_groups", None);
176 self.client
177 .post(
178 &url,
179 crate::Message {
180 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
181 content_type: Some("application/json".to_string()),
182 },
183 )
184 .await
185 }
186 /**
187 * Get a shared line group.
188 *
189 * This function performs a `GET` to the `/phone/shared_line_groups/{sharedLineGroupId}` endpoint.
190 *
191 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. This gives members of the shared line group access to the group's direct phone number and voicemail. Use this API to list all the Shared Line Groups.
192 *
193 * **Prerequisties:** <br>
194 * * Pro or higher account with Zoom Phone license.
195 * * Account owner or admin privileges
196 *
197 * **Scopes:** `phone:read:admin` or `phone:write:admin`
198 *
199 *
200 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
201 *
202 * **Parameters:**
203 *
204 * * `shared_line_group_id: &str` -- Unique Identifier of the Shared Line Group.
205 */
206 pub async fn get_shared_line_group(
207 &self,
208 shared_line_group_id: &str,
209 ) -> ClientResult<crate::Response<crate::types::GetSharedLineGroupResponse>> {
210 let url = self.client.url(
211 &format!(
212 "/phone/shared_line_groups/{}",
213 crate::progenitor_support::encode_path(shared_line_group_id),
214 ),
215 None,
216 );
217 self.client
218 .get(
219 &url,
220 crate::Message {
221 body: None,
222 content_type: None,
223 },
224 )
225 .await
226 }
227 /**
228 * Delete a shared line group.
229 *
230 * This function performs a `DELETE` to the `/phone/shared_line_groups/{sharedLineGroupId}` endpoint.
231 *
232 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. Use this API to delete a Shared Line Group.
233 * **Prerequisties:** <br>
234 * * Pro or higher account with Zoom Phone license.
235 * * Account owner or admin privileges
236 *
237 * **Scopes:** `phone:write:admin`
238 *
239 *
240 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
241 *
242 * **Parameters:**
243 *
244 * * `shared_line_group_id: &str` -- Unique Identifier of the shared line group that you would like to delete.
245 */
246 pub async fn delete_shared_line_group(
247 &self,
248 shared_line_group_id: &str,
249 ) -> ClientResult<crate::Response<()>> {
250 let url = self.client.url(
251 &format!(
252 "/phone/shared_line_groups/{}",
253 crate::progenitor_support::encode_path(shared_line_group_id),
254 ),
255 None,
256 );
257 self.client
258 .delete(
259 &url,
260 crate::Message {
261 body: None,
262 content_type: None,
263 },
264 )
265 .await
266 }
267 /**
268 * Update a shared line group.
269 *
270 * This function performs a `PATCH` to the `/phone/shared_line_groups/{sharedLineGroupId}` endpoint.
271 *
272 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. This gives members of the shared line group access to the group's direct phone number and voicemail. Use this API to update information of a Shared Line Group.
273 * **Prerequisties:** <br>
274 * * Pro or higher account with Zoom Phone license.
275 * * Account owner or admin privileges
276 *
277 * **Scopes:** `phone:write:admin`
278 *
279 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
280 *
281 * **Parameters:**
282 *
283 * * `shared_line_group_id: &str` -- Unique identifier of the shared line group that is to be updated.
284 */
285 pub async fn update_shared_line_group(
286 &self,
287 shared_line_group_id: &str,
288 body: &crate::types::UpdateSharedLineGroupRequest,
289 ) -> ClientResult<crate::Response<()>> {
290 let url = self.client.url(
291 &format!(
292 "/phone/shared_line_groups/{}",
293 crate::progenitor_support::encode_path(shared_line_group_id),
294 ),
295 None,
296 );
297 self.client
298 .patch(
299 &url,
300 crate::Message {
301 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
302 content_type: Some("application/json".to_string()),
303 },
304 )
305 .await
306 }
307 /**
308 * Add members to a shared line group.
309 *
310 * This function performs a `POST` to the `/phone/shared_line_groups/{sharedLineGroupId}/members` endpoint.
311 *
312 * A [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) allows Zoom Phone admins to share a phone number and extension with a group of phone users or common area phones. This gives members of the shared line group access to the group's direct phone number and voicemail. Use this API to [add members](https://support.zoom.us/hc/en-us/articles/360038850792-Setting-up-shared-line-groups#h_7cb42370-48f6-4a8f-84f4-c6eee4d9f0ca) to a Shared Line Group. Note that a member can only be added to one shared line group.
313 *
314 * **Prerequisties:** <br>
315 * * Pro or higher account with Zoom Phone license.
316 * * A valid Shared Line Group
317 * * Account owner or admin privileges
318 *
319 * **Scopes:** `phone:write:admin`
320 *
321 *
322 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
323 *
324 * **Parameters:**
325 *
326 * * `shared_line_group_id: &str` -- Unique Identifier of the shared line group.
327 */
328 pub async fn add_members_shared_line_group(
329 &self,
330 shared_line_group_id: &str,
331 body: &crate::types::AddMembersSharedLineGroupRequestData,
332 ) -> ClientResult<crate::Response<()>> {
333 let url = self.client.url(
334 &format!(
335 "/phone/shared_line_groups/{}/members",
336 crate::progenitor_support::encode_path(shared_line_group_id),
337 ),
338 None,
339 );
340 self.client
341 .post(
342 &url,
343 crate::Message {
344 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
345 content_type: Some("application/json".to_string()),
346 },
347 )
348 .await
349 }
350 /**
351 * Unassign members of a shared line group.
352 *
353 * This function performs a `DELETE` to the `/phone/shared_line_groups/{sharedLineGroupId}/members` endpoint.
354 *
355 * Members of the [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) have access to the group's phone number and voicemail. Use this API to unassign **all** the existing members from a Shared Line Group.
356 * **Prerequisties:** <br>
357 * * Pro or higher account with Zoom Phone license.
358 * * A valid Shared Line Group
359 * * Account owner or admin privileges
360 *
361 * **Scopes:** `phone:write:admin`
362 *
363 *
364 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
365 *
366 * **Parameters:**
367 *
368 * * `shared_line_group_id: &str` -- Unique identifier of the Shared Line Group that you would like to delete.
369 */
370 pub async fn delete_members_of_slg(
371 &self,
372 shared_line_group_id: &str,
373 ) -> ClientResult<crate::Response<()>> {
374 let url = self.client.url(
375 &format!(
376 "/phone/shared_line_groups/{}/members",
377 crate::progenitor_support::encode_path(shared_line_group_id),
378 ),
379 None,
380 );
381 self.client
382 .delete(
383 &url,
384 crate::Message {
385 body: None,
386 content_type: None,
387 },
388 )
389 .await
390 }
391 /**
392 * Unassign a member from a shared line group.
393 *
394 * This function performs a `DELETE` to the `/phone/shared_line_groups/{sharedLineGroupId}/members/{memberId}` endpoint.
395 *
396 * Members of the [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792) have access to the group's phone number and voicemail. Use this API to unassign **a specific member** from a Shared Line Group.
397 * **Prerequisties:** <br>
398 * * Pro or higher account with Zoom Phone license.
399 * * A valid Shared Line Group
400 * * Account owner or admin privileges
401 *
402 * **Scopes:** `phone:write:admin`
403 *
404 *
405 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
406 *
407 * **Parameters:**
408 *
409 * * `shared_line_group_id: &str` -- Unique Identifier of the shared line group from which you would like to remove a member.
410 * * `member_id: &str` -- Unique identifier of the member who is to be removed.
411 */
412 pub async fn delete_member_slg(
413 &self,
414 shared_line_group_id: &str,
415 member_id: &str,
416 ) -> ClientResult<crate::Response<()>> {
417 let url = self.client.url(
418 &format!(
419 "/phone/shared_line_groups/{}/members/{}",
420 crate::progenitor_support::encode_path(shared_line_group_id),
421 crate::progenitor_support::encode_path(member_id),
422 ),
423 None,
424 );
425 self.client
426 .delete(
427 &url,
428 crate::Message {
429 body: None,
430 content_type: None,
431 },
432 )
433 .await
434 }
435 /**
436 * Assign phone numbers.
437 *
438 * This function performs a `POST` to the `/phone/shared_line_groups/{sharedLineGroupId}/phone_numbers` endpoint.
439 *
440 * Use this API to assign phone numbers to a shared line groups. These direct phone numbers will be shared among members of the [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792-Setting-up-shared-line-groups).
441 * **Prerequisties:** <br>
442 * * Pro or higher account with Zoom Phone license.
443 * * A valid Shared Line Group
444 * * Account owner or admin privileges
445 *
446 * **Scopes:** `phone:write:admin`
447 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
448 *
449 * **Parameters:**
450 *
451 * * `shared_line_group_id: &str` -- Unique Identifier of the Shared Line Group.
452 */
453 pub async fn assign_phone_numbers_slg(
454 &self,
455 shared_line_group_id: &str,
456 body: &crate::types::AddByocNumberResponse,
457 ) -> ClientResult<crate::Response<()>> {
458 let url = self.client.url(
459 &format!(
460 "/phone/shared_line_groups/{}/phone_numbers",
461 crate::progenitor_support::encode_path(shared_line_group_id),
462 ),
463 None,
464 );
465 self.client
466 .post(
467 &url,
468 crate::Message {
469 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
470 content_type: Some("application/json".to_string()),
471 },
472 )
473 .await
474 }
475 /**
476 * Unassign all phone numbers.
477 *
478 * This function performs a `DELETE` to the `/phone/shared_line_groups/{sharedLineGroupId}/phone_numbers` endpoint.
479 *
480 * Use this API to unassign all the phone numbers that have been assigned to the [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792-Setting-up-shared-line-groups).
481 * **Prerequisties:** <br>
482 * * Pro or higher account with Zoom Phone license.
483 * * A valid Shared Line Group
484 * * Account owner or admin privileges
485 *
486 * **Scopes:** `phone:write:admin`
487 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
488 *
489 * **Parameters:**
490 *
491 * * `shared_line_group_id: &str` -- Unique Identifier of the Shared Line Group.
492 */
493 pub async fn delete_phone_numbers_slg(
494 &self,
495 shared_line_group_id: &str,
496 ) -> ClientResult<crate::Response<()>> {
497 let url = self.client.url(
498 &format!(
499 "/phone/shared_line_groups/{}/phone_numbers",
500 crate::progenitor_support::encode_path(shared_line_group_id),
501 ),
502 None,
503 );
504 self.client
505 .delete(
506 &url,
507 crate::Message {
508 body: None,
509 content_type: None,
510 },
511 )
512 .await
513 }
514 /**
515 * Unassign a phone number.
516 *
517 * This function performs a `DELETE` to the `/phone/shared_line_groups/{sharedLineGroupId}/phone_numbers/{phoneNumberId}` endpoint.
518 *
519 * Use this API to unassign a specific phone number that was assigned to the [shared line group](https://support.zoom.us/hc/en-us/articles/360038850792-Setting-up-shared-line-groups).
520 * **Prerequisties:** <br>
521 * * Pro or higher account with Zoom Phone license.
522 * * A valid Shared Line Group
523 * * Account owner or admin privileges
524 *
525 * **Scopes:** `phone:write:admin`
526 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
527 *
528 * **Parameters:**
529 *
530 * * `shared_line_group_id: &str` -- Unique identifier of the shared line group from which you would like to unassign a phone number.
531 * * `phone_number_id: &str` -- Unique identifier of the phone number which is to be unassigned. This can be retrieved from Get a Shared Line Group API.
532 */
533 pub async fn delete_phone_number_slg(
534 &self,
535 shared_line_group_id: &str,
536 phone_number_id: &str,
537 ) -> ClientResult<crate::Response<()>> {
538 let url = self.client.url(
539 &format!(
540 "/phone/shared_line_groups/{}/phone_numbers/{}",
541 crate::progenitor_support::encode_path(shared_line_group_id),
542 crate::progenitor_support::encode_path(phone_number_id),
543 ),
544 None,
545 );
546 self.client
547 .delete(
548 &url,
549 crate::Message {
550 body: None,
551 content_type: None,
552 },
553 )
554 .await
555 }
556}