zoom_api/phone_site.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct PhoneSite {
5 pub client: Client,
6}
7
8impl PhoneSite {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 PhoneSite { client }
12 }
13
14 /**
15 * List phone sites.
16 *
17 * This function performs a `GET` to the `/phone/sites` endpoint.
18 *
19 * Sites allow you to organize Zoom Phone users in your organization. Use this API to list all the [sites](https://support.zoom.us/hc/en-us/articles/360020809672) that have been created for an account.<br>
20 * **Prerequisites:**<br>
21 * * Multiple Sites must be [enabled](https://support.zoom.us/hc/en-us/articles/360020809672-Managing-Multiple-Sites#h_05c88e35-1593-491f-b1a8-b7139a75dc15).
22 * * Pro or a higher account with Zoom Phone enabled.
23 *
24 * **Scope:** `phone:read:admin`<br>
25 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
26 *
27 * **Parameters:**
28 *
29 * * `page_size: i64` -- The number of records returned within a single API call.
30 * * `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.
31 */
32 pub async fn list(
33 &self,
34 page_size: i64,
35 next_page_token: &str,
36 ) -> ClientResult<crate::Response<Vec<crate::types::Sites>>> {
37 let mut query_args: Vec<(String, String)> = Default::default();
38 if !next_page_token.is_empty() {
39 query_args.push(("next_page_token".to_string(), next_page_token.to_string()));
40 }
41 if page_size > 0 {
42 query_args.push(("page_size".to_string(), page_size.to_string()));
43 }
44 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
45 let url = self.client.url(&format!("/phone/sites?{}", query_), None);
46 let resp: crate::Response<crate::types::ListPhoneSitesResponse> = self
47 .client
48 .get(
49 &url,
50 crate::Message {
51 body: None,
52 content_type: None,
53 },
54 )
55 .await?;
56
57 // Return our response data.
58 Ok(crate::Response::new(
59 resp.status,
60 resp.headers,
61 resp.body.sites.to_vec(),
62 ))
63 }
64 /**
65 * List phone sites.
66 *
67 * This function performs a `GET` to the `/phone/sites` endpoint.
68 *
69 * As opposed to `list`, this function returns all the pages of the request at once.
70 *
71 * Sites allow you to organize Zoom Phone users in your organization. Use this API to list all the [sites](https://support.zoom.us/hc/en-us/articles/360020809672) that have been created for an account.<br>
72 * **Prerequisites:**<br>
73 * * Multiple Sites must be [enabled](https://support.zoom.us/hc/en-us/articles/360020809672-Managing-Multiple-Sites#h_05c88e35-1593-491f-b1a8-b7139a75dc15).
74 * * Pro or a higher account with Zoom Phone enabled.
75 *
76 * **Scope:** `phone:read:admin`<br>
77 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
78 */
79 pub async fn list_all(&self) -> ClientResult<crate::Response<Vec<crate::types::Sites>>> {
80 let url = self.client.url("/phone/sites", None);
81 let crate::Response::<crate::types::ListPhoneSitesResponse> {
82 mut status,
83 mut headers,
84 mut body,
85 } = self
86 .client
87 .get(
88 &url,
89 crate::Message {
90 body: None,
91 content_type: None,
92 },
93 )
94 .await?;
95
96 let mut sites = body.sites;
97 let mut page = body.next_page_token;
98
99 // Paginate if we should.
100 while !page.is_empty() {
101 // Check if we already have URL params and need to concat the token.
102 if !url.contains('?') {
103 crate::Response::<crate::types::ListPhoneSitesResponse> {
104 status,
105 headers,
106 body,
107 } = self
108 .client
109 .get(
110 &format!("{}?next_page_token={}", url, page),
111 crate::Message {
112 body: None,
113 content_type: None,
114 },
115 )
116 .await?;
117 } else {
118 crate::Response::<crate::types::ListPhoneSitesResponse> {
119 status,
120 headers,
121 body,
122 } = self
123 .client
124 .get(
125 &format!("{}&next_page_token={}", url, page),
126 crate::Message {
127 body: None,
128 content_type: None,
129 },
130 )
131 .await?;
132 }
133
134 sites.append(&mut body.sites);
135
136 if !body.next_page_token.is_empty() && body.next_page_token != page {
137 page = body.next_page_token.to_string();
138 } else {
139 page = "".to_string();
140 }
141 }
142
143 // Return our response data.
144 Ok(crate::Response::new(status, headers, sites))
145 }
146 /**
147 * Create a phone site.
148 *
149 * This function performs a `POST` to the `/phone/sites` endpoint.
150 *
151 * Sites allow you to organize Zoom Phone users in your organization. Use this API to create a [Site](https://support.zoom.us/hc/en-us/articles/360020809672).<br>
152 * **Prerequisites:**<br>
153 * * Multiple Sites must be [enabled](https://support.zoom.us/hc/en-us/articles/360020809672-Managing-Multiple-Sites#h_05c88e35-1593-491f-b1a8-b7139a75dc15).
154 * * Pro or a higher account with Zoom Phone enabled.
155 * **Scope:** `phone:write:admin`<br>
156 *
157 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
158 *
159 *
160 */
161 pub async fn create(
162 &self,
163 body: &crate::types::CreatePhoneSiteRequest,
164 ) -> ClientResult<crate::Response<crate::types::Site>> {
165 let url = self.client.url("/phone/sites", None);
166 self.client
167 .post(
168 &url,
169 crate::Message {
170 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
171 content_type: Some("application/json".to_string()),
172 },
173 )
174 .await
175 }
176 /**
177 * Get phone site details.
178 *
179 * This function performs a `GET` to the `/phone/sites/{siteId}` endpoint.
180 *
181 * Sites allow you to organize Zoom Phone users in your organization. Use this API to get information about a specific [site](https://support.zoom.us/hc/en-us/articles/360020809672).
182 *
183 *
184 * **Prerequisites:** <br>
185 * * Account must have a Pro or a higher plan with Zoom Phone license.
186 * * Multiple Sites must be [enabled](https://support.zoom.us/hc/en-us/articles/360020809672-Managing-Multiple-Sites#h_05c88e35-1593-491f-b1a8-b7139a75dc15).<br>
187 * **Scope:** `phone:read:admin`<br>
188 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
189 *
190 *
191 *
192 * **Parameters:**
193 *
194 * * `site_id: &str` -- Unique Identifier of the Site.
195 */
196 pub async fn get_site(
197 &self,
198 site_id: &str,
199 ) -> ClientResult<crate::Response<crate::types::GetSiteResponse>> {
200 let url = self.client.url(
201 &format!(
202 "/phone/sites/{}",
203 crate::progenitor_support::encode_path(site_id),
204 ),
205 None,
206 );
207 self.client
208 .get(
209 &url,
210 crate::Message {
211 body: None,
212 content_type: None,
213 },
214 )
215 .await
216 }
217 /**
218 * Delete a phone site.
219 *
220 * This function performs a `DELETE` to the `/phone/sites/{siteId}` endpoint.
221 *
222 * Sites allow you to organize Zoom Phone users in your organization. Use this API to delete a specific [site](https://support.zoom.us/hc/en-us/articles/360020809672) in a Zoom account. To delete a site, in the query parameter, you must provide the Site ID of another site where the assets of current site (users, numbers and phones) can be transferred to. You cannot use this API to delete the main site.
223 *
224 * **Prerequisites:** <br>
225 * * Account must have a Pro or a higher plan with Zoom Phone license.
226 * * [Multiple Sites](https://support.zoom.us/hc/en-us/articles/360020809672-Managing-Multiple-Sites) must be enabled.<br>
227 * **Scope:** `phone:write:admin`
228 * <br>
229 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
230 *
231 *
232 *
233 * **Parameters:**
234 *
235 * * `site_id: &str` -- Unique Identifier of the Site.
236 * * `transfer_site_id: &str` -- The Site ID of another site where the assets of the current site (users, numbers and phones) can be transferred to.
237 */
238 pub async fn delete(
239 &self,
240 site_id: &str,
241 transfer_site_id: &str,
242 ) -> ClientResult<crate::Response<()>> {
243 let mut query_args: Vec<(String, String)> = Default::default();
244 if !transfer_site_id.is_empty() {
245 query_args.push(("transfer_site_id".to_string(), transfer_site_id.to_string()));
246 }
247 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
248 let url = self.client.url(
249 &format!(
250 "/phone/sites/{}?{}",
251 crate::progenitor_support::encode_path(site_id),
252 query_
253 ),
254 None,
255 );
256 self.client
257 .delete(
258 &url,
259 crate::Message {
260 body: None,
261 content_type: None,
262 },
263 )
264 .await
265 }
266 /**
267 * Update phone site details.
268 *
269 * This function performs a `PATCH` to the `/phone/sites/{siteId}` endpoint.
270 *
271 * Sites allow you to organize Zoom Phone users in your organization. Use this API to update information about a specific [site](https://support.zoom.us/hc/en-us/articles/360020809672).
272 *
273 *
274 * **Prerequisites:** <br>
275 * * Account must have a Pro or a higher plan with Zoom Phone license.
276 * * **Scope:** `phone:write:admin`<br>
277 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
278 *
279 *
280 *
281 * **Parameters:**
282 *
283 * * `site_id: &str` -- Unique Identifier of the Site.
284 */
285 pub async fn update_site_details(
286 &self,
287 site_id: &str,
288 body: &crate::types::UpdateSiteDetailsRequest,
289 ) -> ClientResult<crate::Response<()>> {
290 let url = self.client.url(
291 &format!(
292 "/phone/sites/{}",
293 crate::progenitor_support::encode_path(site_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}