zoom_api/
contacts.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Contacts {
5    pub client: Client,
6}
7
8impl Contacts {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Contacts { client }
12    }
13
14    /**
15     * Search company contacts.
16     *
17     * This function performs a `GET` to the `/contacts` endpoint.
18     *
19     * A user under an organization's Zoom account has internal users listed under Company Contacts in the Zoom Client. Use this API to search users that are in the company contacts of a Zoom account. Using the `search_key` query parameter, provide either first name, last name or the email address of the user that you would like to search for. Optionally, set `query_presence_status` to `true` in order to include the presence status of a contact. <br><br>
20     *
21     * **Scopes:** `contact:read:admin`, `contact:read`<br>
22     *
23     *  **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
24     *
25     * **Parameters:**
26     *
27     * * `search_key: &str` -- Provide the keyword - either first name, last name or email of the contact whom you have to search for.
28     * * `query_presence_status: &str` -- Set `query_presence_status` to `true` in order to include the presence status of a contact in the response.
29     * * `page_size: i64` -- The number of records to be returned with 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 search_company(
33        &self,
34        search_key: &str,
35        query_presence_status: &str,
36        page_size: i64,
37        next_page_token: &str,
38    ) -> ClientResult<crate::Response<Vec<crate::types::Contacts>>> {
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        if !query_presence_status.is_empty() {
47            query_args.push((
48                "query_presence_status".to_string(),
49                query_presence_status.to_string(),
50            ));
51        }
52        if !search_key.is_empty() {
53            query_args.push(("search_key".to_string(), search_key.to_string()));
54        }
55        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
56        let url = self.client.url(&format!("/contacts?{}", query_), None);
57        let resp: crate::Response<crate::types::SearchCompanyContactsResponse> = self
58            .client
59            .get(
60                &url,
61                crate::Message {
62                    body: None,
63                    content_type: None,
64                },
65            )
66            .await?;
67
68        // Return our response data.
69        Ok(crate::Response::new(
70            resp.status,
71            resp.headers,
72            resp.body.contacts.to_vec(),
73        ))
74    }
75    /**
76     * Search company contacts.
77     *
78     * This function performs a `GET` to the `/contacts` endpoint.
79     *
80     * As opposed to `search_company`, this function returns all the pages of the request at once.
81     *
82     * A user under an organization's Zoom account has internal users listed under Company Contacts in the Zoom Client. Use this API to search users that are in the company contacts of a Zoom account. Using the `search_key` query parameter, provide either first name, last name or the email address of the user that you would like to search for. Optionally, set `query_presence_status` to `true` in order to include the presence status of a contact. <br><br>
83     *
84     * **Scopes:** `contact:read:admin`, `contact:read`<br>
85     *
86     *  **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
87     */
88    pub async fn get_all_search_company(
89        &self,
90        search_key: &str,
91        query_presence_status: &str,
92    ) -> ClientResult<crate::Response<Vec<crate::types::Contacts>>> {
93        let mut query_args: Vec<(String, String)> = Default::default();
94        if !query_presence_status.is_empty() {
95            query_args.push((
96                "query_presence_status".to_string(),
97                query_presence_status.to_string(),
98            ));
99        }
100        if !search_key.is_empty() {
101            query_args.push(("search_key".to_string(), search_key.to_string()));
102        }
103        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
104        let url = self.client.url(&format!("/contacts?{}", query_), None);
105        let crate::Response::<crate::types::SearchCompanyContactsResponse> {
106            mut status,
107            mut headers,
108            mut body,
109        } = self
110            .client
111            .get(
112                &url,
113                crate::Message {
114                    body: None,
115                    content_type: None,
116                },
117            )
118            .await?;
119
120        let mut contacts = body.contacts;
121        let mut page = body.next_page_token;
122
123        // Paginate if we should.
124        while !page.is_empty() {
125            // Check if we already have URL params and need to concat the token.
126            if !url.contains('?') {
127                crate::Response::<crate::types::SearchCompanyContactsResponse> {
128                    status,
129                    headers,
130                    body,
131                } = self
132                    .client
133                    .get(
134                        &format!("{}?next_page_token={}", url, page),
135                        crate::Message {
136                            body: None,
137                            content_type: None,
138                        },
139                    )
140                    .await?;
141            } else {
142                crate::Response::<crate::types::SearchCompanyContactsResponse> {
143                    status,
144                    headers,
145                    body,
146                } = self
147                    .client
148                    .get(
149                        &format!("{}&next_page_token={}", url, page),
150                        crate::Message {
151                            body: None,
152                            content_type: None,
153                        },
154                    )
155                    .await?;
156            }
157
158            contacts.append(&mut body.contacts);
159
160            if !body.next_page_token.is_empty() && body.next_page_token != page {
161                page = body.next_page_token.to_string();
162            } else {
163                page = "".to_string();
164            }
165        }
166
167        // Return our response data.
168        Ok(crate::Response::new(status, headers, contacts))
169    }
170    /**
171     * List user's contacts.
172     *
173     * This function performs a `GET` to the `/chat/users/me/contacts` endpoint.
174     *
175     * A user under an organization’s Zoom account has internal users listed under Company Contacts in the Zoom Client. A Zoom user can also add another Zoom user as a [contact](https://support.zoom.us/hc/en-us/articles/115004055706-Managing-Contacts). Call this API to list all the contacts of a Zoom user. Zoom contacts are categorized into "company contacts" and "external contacts". You must specify the contact type in the `type` query parameter. If you do not specify, by default, the type will be set as company contact.
176     *
177     * <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>
178     *
179     * **Scope**: `chat_contact:read`<br>
180     *
181     *  **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
182     *
183     * **Parameters:**
184     *
185     * * `type_: &str` -- The type of contact. The value can be one of the following:
186     *   `company`: Contacts from the user's organization.
187     *   `external`: External contacts. .
188     * * `page_size: i64` -- The number of records returned with a single API call.
189     * * `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.
190     */
191    pub async fn get_user(
192        &self,
193        type_: &str,
194        page_size: i64,
195        next_page_token: &str,
196    ) -> ClientResult<crate::Response<Vec<crate::types::GetUserContactsResponse>>> {
197        let mut query_args: Vec<(String, String)> = Default::default();
198        if !next_page_token.is_empty() {
199            query_args.push(("next_page_token".to_string(), next_page_token.to_string()));
200        }
201        if page_size > 0 {
202            query_args.push(("page_size".to_string(), page_size.to_string()));
203        }
204        if !type_.is_empty() {
205            query_args.push(("type".to_string(), type_.to_string()));
206        }
207        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
208        let url = self
209            .client
210            .url(&format!("/chat/users/me/contacts?{}", query_), None);
211        let resp: crate::Response<crate::types::GetUserContactsResponseData> = self
212            .client
213            .get(
214                &url,
215                crate::Message {
216                    body: None,
217                    content_type: None,
218                },
219            )
220            .await?;
221
222        // Return our response data.
223        Ok(crate::Response::new(
224            resp.status,
225            resp.headers,
226            resp.body.contacts.to_vec(),
227        ))
228    }
229    /**
230     * List user's contacts.
231     *
232     * This function performs a `GET` to the `/chat/users/me/contacts` endpoint.
233     *
234     * As opposed to `get_user`, this function returns all the pages of the request at once.
235     *
236     * A user under an organization’s Zoom account has internal users listed under Company Contacts in the Zoom Client. A Zoom user can also add another Zoom user as a [contact](https://support.zoom.us/hc/en-us/articles/115004055706-Managing-Contacts). Call this API to list all the contacts of a Zoom user. Zoom contacts are categorized into "company contacts" and "external contacts". You must specify the contact type in the `type` query parameter. If you do not specify, by default, the type will be set as company contact.
237     *
238     * <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>
239     *
240     * **Scope**: `chat_contact:read`<br>
241     *
242     *  **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
243     */
244    pub async fn get_all_user(
245        &self,
246        type_: &str,
247    ) -> ClientResult<crate::Response<Vec<crate::types::GetUserContactsResponse>>> {
248        let mut query_args: Vec<(String, String)> = Default::default();
249        if !type_.is_empty() {
250            query_args.push(("type".to_string(), type_.to_string()));
251        }
252        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
253        let url = self
254            .client
255            .url(&format!("/chat/users/me/contacts?{}", query_), None);
256        let crate::Response::<crate::types::GetUserContactsResponseData> {
257            mut status,
258            mut headers,
259            mut body,
260        } = self
261            .client
262            .get(
263                &url,
264                crate::Message {
265                    body: None,
266                    content_type: None,
267                },
268            )
269            .await?;
270
271        let mut contacts = body.contacts;
272        let mut page = body.next_page_token;
273
274        // Paginate if we should.
275        while !page.is_empty() {
276            // Check if we already have URL params and need to concat the token.
277            if !url.contains('?') {
278                crate::Response::<crate::types::GetUserContactsResponseData> {
279                    status,
280                    headers,
281                    body,
282                } = self
283                    .client
284                    .get(
285                        &format!("{}?next_page_token={}", url, page),
286                        crate::Message {
287                            body: None,
288                            content_type: None,
289                        },
290                    )
291                    .await?;
292            } else {
293                crate::Response::<crate::types::GetUserContactsResponseData> {
294                    status,
295                    headers,
296                    body,
297                } = self
298                    .client
299                    .get(
300                        &format!("{}&next_page_token={}", url, page),
301                        crate::Message {
302                            body: None,
303                            content_type: None,
304                        },
305                    )
306                    .await?;
307            }
308
309            contacts.append(&mut body.contacts);
310
311            if !body.next_page_token.is_empty() && body.next_page_token != page {
312                page = body.next_page_token.to_string();
313            } else {
314                page = "".to_string();
315            }
316        }
317
318        // Return our response data.
319        Ok(crate::Response::new(status, headers, contacts))
320    }
321    /**
322     * Get user's contact details.
323     *
324     * This function performs a `GET` to the `/chat/users/me/contacts/{contactId}` endpoint.
325     *
326     * A user under an organization’s Zoom account has internal users listed under Company Contacts in the Zoom Client. A Zoom user can also add another Zoom user as a [contact](https://support.zoom.us/hc/en-us/articles/115004055706-Managing-Contacts). Call this API to get information on a specific contact of the Zoom user.
327     *
328     * <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>
329     *
330     * **Scope**: `chat_contact:read`<br>
331     *
332     *  **[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Medium`
333     *
334     * **Parameters:**
335     *
336     * * `contact_id: &str` -- The user's contact Id or email address. The contact can be either a company contact or an external contact.
337     * * `query_presence_status: bool` -- Enable/disable the option for a sub account to use shared [Virtual Room Connector(s)](https://support.zoom.us/hc/en-us/articles/202134758-Getting-Started-With-Virtual-Room-Connector) that are set up by the master account. Virtual Room Connectors can only be used by On-prem users.
338     */
339    pub async fn get_user_contacts(
340        &self,
341        contact_id: &str,
342        query_presence_status: bool,
343    ) -> ClientResult<crate::Response<crate::types::GetUserContactResponse>> {
344        let mut query_args: Vec<(String, String)> = Default::default();
345        if query_presence_status {
346            query_args.push((
347                "query_presence_status".to_string(),
348                query_presence_status.to_string(),
349            ));
350        }
351        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
352        let url = self.client.url(
353            &format!(
354                "/chat/users/me/contacts/{}?{}",
355                crate::progenitor_support::encode_path(contact_id),
356                query_
357            ),
358            None,
359        );
360        self.client
361            .get(
362                &url,
363                crate::Message {
364                    body: None,
365                    content_type: None,
366                },
367            )
368            .await
369    }
370}