zoom_api/sip_phone.rs
1use crate::Client;
2use crate::ClientResult;
3
4pub struct SipPhone {
5 pub client: Client,
6}
7
8impl SipPhone {
9 #[doc(hidden)]
10 pub fn new(client: Client) -> Self {
11 SipPhone { client }
12 }
13
14 /**
15 * List SIP phones.
16 *
17 * This function performs a `GET` to the `/sip_phones` endpoint.
18 *
19 * Zoom’s Phone System Integration (PSI), also referred as SIP phones, enables an organization to leverage the Zoom client to complete a softphone registration to supported premise based PBX system. End users will have the ability to have softphone functionality within a single client while maintaining a comparable interface to Zoom Phone. Use this API to list SIP phones on an account.<br><br>
20 * **Prerequisites**:
21 * * Currently only supported on Cisco and Avaya PBX systems.
22 * * User must enable SIP Phone Integration by contacting the [Sales](https://zoom.us/contactsales) team.<br> **Scope:** `sip_phone:read:admin`<br>
23 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`<br>
24 *
25 *
26 * **Parameters:**
27 *
28 * * `page_number: i64` --
29 * **Deprecated** - This field has been deprecated and we will stop supporting it completely in a future release. Please use "next_page_token" for pagination instead of this field.
30 *
31 * The page number of the current page in the returned records.
32 * * `search_key: &str` -- User name or email address of a user. If this parameter is provided, only the SIP phone system integration enabled for that specific user will be returned. Otherwise, all SIP phones on an account will be returned.
33 * * `page_size: i64` -- The number of records returned within a single API call.
34 * * `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.
35 */
36 pub async fn list(
37 &self,
38 page_number: i64,
39 search_key: &str,
40 page_size: i64,
41 next_page_token: &str,
42 ) -> ClientResult<crate::Response<Vec<crate::types::Phones>>> {
43 let mut query_args: Vec<(String, String)> = Default::default();
44 if !next_page_token.is_empty() {
45 query_args.push(("next_page_token".to_string(), next_page_token.to_string()));
46 }
47 if page_number > 0 {
48 query_args.push(("page_number".to_string(), page_number.to_string()));
49 }
50 if page_size > 0 {
51 query_args.push(("page_size".to_string(), page_size.to_string()));
52 }
53 if !search_key.is_empty() {
54 query_args.push(("search_key".to_string(), search_key.to_string()));
55 }
56 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
57 let url = self.client.url(&format!("/sip_phones?{}", query_), None);
58 let resp: crate::Response<crate::types::ListSipPhonesResponse> = self
59 .client
60 .get(
61 &url,
62 crate::Message {
63 body: None,
64 content_type: None,
65 },
66 )
67 .await?;
68
69 // Return our response data.
70 Ok(crate::Response::new(
71 resp.status,
72 resp.headers,
73 resp.body.phones.to_vec(),
74 ))
75 }
76 /**
77 * List SIP phones.
78 *
79 * This function performs a `GET` to the `/sip_phones` endpoint.
80 *
81 * As opposed to `list`, this function returns all the pages of the request at once.
82 *
83 * Zoom’s Phone System Integration (PSI), also referred as SIP phones, enables an organization to leverage the Zoom client to complete a softphone registration to supported premise based PBX system. End users will have the ability to have softphone functionality within a single client while maintaining a comparable interface to Zoom Phone. Use this API to list SIP phones on an account.<br><br>
84 * **Prerequisites**:
85 * * Currently only supported on Cisco and Avaya PBX systems.
86 * * User must enable SIP Phone Integration by contacting the [Sales](https://zoom.us/contactsales) team.<br> **Scope:** `sip_phone:read:admin`<br>
87 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`<br>
88 *
89 */
90 pub async fn list_all(
91 &self,
92 search_key: &str,
93 ) -> ClientResult<crate::Response<Vec<crate::types::Phones>>> {
94 let mut query_args: Vec<(String, String)> = Default::default();
95 if !search_key.is_empty() {
96 query_args.push(("search_key".to_string(), search_key.to_string()));
97 }
98 let query_ = serde_urlencoded::to_string(&query_args).unwrap();
99 let url = self.client.url(&format!("/sip_phones?{}", query_), None);
100 let crate::Response::<crate::types::ListSipPhonesResponse> {
101 mut status,
102 mut headers,
103 mut body,
104 } = self
105 .client
106 .get(
107 &url,
108 crate::Message {
109 body: None,
110 content_type: None,
111 },
112 )
113 .await?;
114
115 let mut phones = body.phones;
116 let mut page = body.next_page_token;
117
118 // Paginate if we should.
119 while !page.is_empty() {
120 // Check if we already have URL params and need to concat the token.
121 if !url.contains('?') {
122 crate::Response::<crate::types::ListSipPhonesResponse> {
123 status,
124 headers,
125 body,
126 } = self
127 .client
128 .get(
129 &format!("{}?next_page_token={}", url, page),
130 crate::Message {
131 body: None,
132 content_type: None,
133 },
134 )
135 .await?;
136 } else {
137 crate::Response::<crate::types::ListSipPhonesResponse> {
138 status,
139 headers,
140 body,
141 } = self
142 .client
143 .get(
144 &format!("{}&next_page_token={}", url, page),
145 crate::Message {
146 body: None,
147 content_type: None,
148 },
149 )
150 .await?;
151 }
152
153 phones.append(&mut body.phones);
154
155 if !body.next_page_token.is_empty() && body.next_page_token != page {
156 page = body.next_page_token.to_string();
157 } else {
158 page = "".to_string();
159 }
160 }
161
162 // Return our response data.
163 Ok(crate::Response::new(status, headers, phones))
164 }
165 /**
166 * Enable SIP phone.
167 *
168 * This function performs a `POST` to the `/sip_phones` endpoint.
169 *
170 * Zoom’s Phone System Integration (PSI), also referred as SIP phones, enables an organization to leverage the Zoom client to complete a softphone registration to supported premise based PBX system. End users will have the ability to have softphone functionality within a single client while maintaining a comparable interface to Zoom Phone. Use this API to enable a user to use SIP phone.<br><br>
171 * **Prerequisites**:
172 * * Currently only supported on Cisco and Avaya PBX systems.
173 * * The account owner or account admin must first enable SIP Phone Integration by contacting the [Sales](https://zoom.us/contactsales) team.<br> **Scope:** `sip_phone:write:admin`
174 * <br>
175 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
176 *
177 *
178 */
179 pub async fn create(
180 &self,
181 body: &crate::types::CreateSipPhoneRequest,
182 ) -> ClientResult<crate::Response<()>> {
183 let url = self.client.url("/sip_phones", None);
184 self.client
185 .post(
186 &url,
187 crate::Message {
188 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
189 content_type: Some("application/json".to_string()),
190 },
191 )
192 .await
193 }
194 /**
195 * Delete SIP phone.
196 *
197 * This function performs a `DELETE` to the `/sip_phones/{phoneId}` endpoint.
198 *
199 * Zoom’s Phone System Integration (PSI), also referred as SIP phones, enables an organization to leverage the Zoom client to complete a softphone registration to supported premise based PBX system. End users will have the ability to have softphone functionality within a single client while maintaining a comparable interface to Zoom Phone. Use this API to delete a specific SIP phone on a Zoom account.<br><br>
200 * **Prerequisites**:
201 * * Currently only supported on Cisco and Avaya PBX systems.
202 * * User must enable SIP Phone Integration by contacting the [Sales](https://zoom.us/contactsales) team.<br> **Scope:** `sip_phone:read:admin`
203 * <br>
204 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
205 *
206 * **Parameters:**
207 *
208 * * `phone_id: &str` -- Unique Identifier of the SIP Phone. It can be retrieved from the List SIP Phones API.
209 */
210 pub async fn delete(&self, phone_id: &str) -> ClientResult<crate::Response<()>> {
211 let url = self.client.url(
212 &format!(
213 "/sip_phones/{}",
214 crate::progenitor_support::encode_path(phone_id),
215 ),
216 None,
217 );
218 self.client
219 .delete(
220 &url,
221 crate::Message {
222 body: None,
223 content_type: None,
224 },
225 )
226 .await
227 }
228 /**
229 * Update SIP phone.
230 *
231 * This function performs a `PATCH` to the `/sip_phones/{phoneId}` endpoint.
232 *
233 * Zoom’s Phone System Integration (PSI), also referred as SIP phones, enables an organization to leverage the Zoom client to complete a softphone registration to supported premise based PBX system. End users will have the ability to have softphone functionality within a single client while maintaining a comparable interface to Zoom Phone. Use this API to update information of a specific SIP Phone on a Zoom account.<br><br>
234 * **Prerequisites**:
235 * * Currently only supported on Cisco and Avaya PBX systems.
236 * * The account owner or account admin must first enable SIP Phone Integration by contacting the [Sales](https://zoom.us/contactsales) team.<br> **Scope:** `sip_phone:write:admin`
237 * <br>
238 * **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`
239 *
240 * **Parameters:**
241 *
242 * * `phone_id: &str` -- Unique Identifier of the SIP Phone. This can be retrieved from the List SIP Phones API.
243 */
244 pub async fn update(
245 &self,
246 phone_id: &str,
247 body: &crate::types::UpdateSipPhoneRequest,
248 ) -> ClientResult<crate::Response<()>> {
249 let url = self.client.url(
250 &format!(
251 "/sip_phones/{}",
252 crate::progenitor_support::encode_path(phone_id),
253 ),
254 None,
255 );
256 self.client
257 .patch(
258 &url,
259 crate::Message {
260 body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
261 content_type: Some("application/json".to_string()),
262 },
263 )
264 .await
265 }
266}