front_api/
conversations.rs

1use anyhow::Result;
2
3use crate::Client;
4#[derive(Clone, Debug)]
5pub struct Conversations {
6    pub client: Client,
7}
8
9impl Conversations {
10    #[doc(hidden)]
11    pub fn new(client: Client) -> Self {
12        Self { client }
13    }
14
15    #[doc = "List conversations\n\nList the conversations in the company in reverse chronological order (most recently updated first). For more advanced filtering, see the [search endpoint](https://dev.frontapp.com/reference/conversations#search-conversations).\n> ⚠\u{fe0f} Deprecated field included\n>\n> This endpoint returns a deprecated `last_message` field in the top-level conversation bodies listed. Please use the\n> `_links.related.last_message` field instead.\n\n\n**Parameters:**\n\n- `limit: Option<i64>`: Max number of results per page\n- `page_token: Option<String>`: Token to use to request the next page\n- `q: Option<String>`: Search query object with a property `statuses`, whose value should be a list of conversation statuses (`assigned`, `unassigned`, `archived`, or `deleted`).\n\n```rust,no_run\nasync fn example_conversations_list() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let result: front_api::types::ListConversationsResponse = client\n        .conversations()\n        .list(\n            Some(4 as i64),\n            Some(\"some-string\".to_string()),\n            Some(\"some-string\".to_string()),\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
16    #[tracing::instrument]
17    pub async fn list<'a>(
18        &'a self,
19        limit: Option<i64>,
20        page_token: Option<String>,
21        q: Option<String>,
22    ) -> Result<crate::types::ListConversationsResponse, crate::types::error::Error> {
23        let mut req = self.client.client.request(
24            http::Method::GET,
25            &format!("{}/{}", self.client.base_url, "conversations"),
26        );
27        req = req.bearer_auth(&self.client.token);
28        let mut query_params = Vec::new();
29        if let Some(p) = limit {
30            query_params.push(("limit", format!("{}", p)));
31        }
32
33        if let Some(p) = page_token {
34            query_params.push(("page_token", p));
35        }
36
37        if let Some(p) = q {
38            query_params.push(("q", p));
39        }
40
41        req = req.query(&query_params);
42        let resp = req.send().await?;
43        let status = resp.status();
44        if status.is_success() {
45            let text = resp.text().await.unwrap_or_default();
46            serde_json::from_str(&text).map_err(|err| {
47                crate::types::error::Error::from_serde_error(
48                    format_serde_error::SerdeError::new(text.to_string(), err),
49                    status,
50                )
51            })
52        } else {
53            Err(crate::types::error::Error::UnexpectedResponse(resp))
54        }
55    }
56
57    #[doc = "Create conversation\n\nCreate a conversation.\n> ⚠\u{fe0f} Currently, only discussions can be created with this endpoint.\n\n\n```rust,no_run\nasync fn example_conversations_create() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let result: front_api::types::ConversationResponse = client\n        .conversations()\n        .create(&serde_json::Value::String(\"some-string\".to_string()))\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
58    #[tracing::instrument]
59    pub async fn create<'a>(
60        &'a self,
61        body: &crate::types::CreateConversation,
62    ) -> Result<crate::types::ConversationResponse, crate::types::error::Error> {
63        let mut req = self.client.client.request(
64            http::Method::POST,
65            &format!("{}/{}", self.client.base_url, "conversations"),
66        );
67        req = req.bearer_auth(&self.client.token);
68        req = req.json(body);
69        let resp = req.send().await?;
70        let status = resp.status();
71        if status.is_success() {
72            let text = resp.text().await.unwrap_or_default();
73            serde_json::from_str(&text).map_err(|err| {
74                crate::types::error::Error::from_serde_error(
75                    format_serde_error::SerdeError::new(text.to_string(), err),
76                    status,
77                )
78            })
79        } else {
80            Err(crate::types::error::Error::UnexpectedResponse(resp))
81        }
82    }
83
84    #[doc = "Get conversation\n\nFetch a conversation.\n> ⚠\u{fe0f} Deprecated field \
85             included\n>\n> This endpoint returns a deprecated `last_message` field in the main \
86             body. Please use the\n> `_links.related.last_message` field \
87             instead.\n\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID \
88             (required)\n\n```rust,no_run\nasync fn example_conversations_get_by_id() -> \
89             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let \
90             result: front_api::types::ConversationResponse =\n        \
91             client.conversations().get_by_id(\"some-string\").await?;\n    println!(\"{:?}\", \
92             result);\n    Ok(())\n}\n```"]
93    #[tracing::instrument]
94    pub async fn get_by_id<'a>(
95        &'a self,
96        conversation_id: &'a str,
97    ) -> Result<crate::types::ConversationResponse, crate::types::error::Error> {
98        let mut req = self.client.client.request(
99            http::Method::GET,
100            &format!(
101                "{}/{}",
102                self.client.base_url,
103                "conversations/{conversation_id}".replace("{conversation_id}", conversation_id)
104            ),
105        );
106        req = req.bearer_auth(&self.client.token);
107        let resp = req.send().await?;
108        let status = resp.status();
109        if status.is_success() {
110            let text = resp.text().await.unwrap_or_default();
111            serde_json::from_str(&text).map_err(|err| {
112                crate::types::error::Error::from_serde_error(
113                    format_serde_error::SerdeError::new(text.to_string(), err),
114                    status,
115                )
116            })
117        } else {
118            Err(crate::types::error::Error::UnexpectedResponse(resp))
119        }
120    }
121
122    #[doc = "Update conversation\n\nUpdate a conversation.\n\n**Parameters:**\n\n- \
123             `conversation_id: &'astr`: The conversation ID (required)\n\n```rust,no_run\nasync fn \
124             example_conversations_update() -> anyhow::Result<()> {\n    let client = \
125             front_api::Client::new_from_env();\n    client\n        .conversations()\n        \
126             .update(\n            \"some-string\",\n            \
127             &serde_json::Value::String(\"some-string\".to_string()),\n        )\n        \
128             .await?;\n    Ok(())\n}\n```"]
129    #[tracing::instrument]
130    pub async fn update<'a>(
131        &'a self,
132        conversation_id: &'a str,
133        body: &crate::types::UpdateConversation,
134    ) -> Result<(), crate::types::error::Error> {
135        let mut req = self.client.client.request(
136            http::Method::PATCH,
137            &format!(
138                "{}/{}",
139                self.client.base_url,
140                "conversations/{conversation_id}".replace("{conversation_id}", conversation_id)
141            ),
142        );
143        req = req.bearer_auth(&self.client.token);
144        req = req.json(body);
145        let resp = req.send().await?;
146        let status = resp.status();
147        if status.is_success() {
148            Ok(())
149        } else {
150            Err(crate::types::error::Error::UnexpectedResponse(resp))
151        }
152    }
153
154    #[doc = "Update conversation assignee\n\nAssign or unassign a \
155             conversation.\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID \
156             (required)\n\n```rust,no_run\nasync fn example_conversations_update_assignee() -> \
157             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    \
158             client\n        .conversations()\n        .update_assignee(\n            \
159             \"some-string\",\n            \
160             &serde_json::Value::String(\"some-string\".to_string()),\n        )\n        \
161             .await?;\n    Ok(())\n}\n```"]
162    #[tracing::instrument]
163    pub async fn update_assignee<'a>(
164        &'a self,
165        conversation_id: &'a str,
166        body: &crate::types::UpdateConversationAssignee,
167    ) -> Result<(), crate::types::error::Error> {
168        let mut req = self.client.client.request(
169            http::Method::PUT,
170            &format!(
171                "{}/{}",
172                self.client.base_url,
173                "conversations/{conversation_id}/assignee"
174                    .replace("{conversation_id}", conversation_id)
175            ),
176        );
177        req = req.bearer_auth(&self.client.token);
178        req = req.json(body);
179        let resp = req.send().await?;
180        let status = resp.status();
181        if status.is_success() {
182            Ok(())
183        } else {
184            Err(crate::types::error::Error::UnexpectedResponse(resp))
185        }
186    }
187
188    #[doc = "Add conversation tag\n\nAdds one or more tags to a conversation\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID (required)\n\n```rust,no_run\nasync fn example_conversations_add_tag() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    client\n        .conversations()\n        .add_tag(\n            \"some-string\",\n            &front_api::types::TagIds {\n                tag_ids: vec![\"some-string\".to_string()],\n            },\n        )\n        .await?;\n    Ok(())\n}\n```"]
189    #[tracing::instrument]
190    pub async fn add_tag<'a>(
191        &'a self,
192        conversation_id: &'a str,
193        body: &crate::types::TagIds,
194    ) -> Result<(), crate::types::error::Error> {
195        let mut req = self.client.client.request(
196            http::Method::POST,
197            &format!(
198                "{}/{}",
199                self.client.base_url,
200                "conversations/{conversation_id}/tags"
201                    .replace("{conversation_id}", conversation_id)
202            ),
203        );
204        req = req.bearer_auth(&self.client.token);
205        req = req.json(body);
206        let resp = req.send().await?;
207        let status = resp.status();
208        if status.is_success() {
209            Ok(())
210        } else {
211            Err(crate::types::error::Error::UnexpectedResponse(resp))
212        }
213    }
214
215    #[doc = "Remove conversation tag\n\nRemoves one or more tags to a \
216             conversation\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID \
217             (required)\n\n```rust,no_run\nasync fn example_conversations_remove_tag() -> \
218             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    \
219             client\n        .conversations()\n        .remove_tag(\n            \
220             \"some-string\",\n            &front_api::types::TagIds {\n                tag_ids: \
221             vec![\"some-string\".to_string()],\n            },\n        )\n        .await?;\n    \
222             Ok(())\n}\n```"]
223    #[tracing::instrument]
224    pub async fn remove_tag<'a>(
225        &'a self,
226        conversation_id: &'a str,
227        body: &crate::types::TagIds,
228    ) -> Result<(), crate::types::error::Error> {
229        let mut req = self.client.client.request(
230            http::Method::DELETE,
231            &format!(
232                "{}/{}",
233                self.client.base_url,
234                "conversations/{conversation_id}/tags"
235                    .replace("{conversation_id}", conversation_id)
236            ),
237        );
238        req = req.bearer_auth(&self.client.token);
239        req = req.json(body);
240        let resp = req.send().await?;
241        let status = resp.status();
242        if status.is_success() {
243            Ok(())
244        } else {
245            Err(crate::types::error::Error::UnexpectedResponse(resp))
246        }
247    }
248
249    #[doc = "Add conversation link\n\nAdds one or more links to a conversation\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID (required)\n\n```rust,no_run\nasync fn example_conversations_add_link() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    client\n        .conversations()\n        .add_link(\n            \"some-string\",\n            &front_api::types::AddConversationLinkRequestBody {\n                link_ids: Some(vec![\"some-string\".to_string()]),\n                link_external_urls: Some(vec![\"some-string\".to_string()]),\n            },\n        )\n        .await?;\n    Ok(())\n}\n```"]
250    #[tracing::instrument]
251    pub async fn add_link<'a>(
252        &'a self,
253        conversation_id: &'a str,
254        body: &crate::types::AddConversationLinkRequestBody,
255    ) -> Result<(), crate::types::error::Error> {
256        let mut req = self.client.client.request(
257            http::Method::POST,
258            &format!(
259                "{}/{}",
260                self.client.base_url,
261                "conversations/{conversation_id}/links"
262                    .replace("{conversation_id}", conversation_id)
263            ),
264        );
265        req = req.bearer_auth(&self.client.token);
266        req = req.json(body);
267        let resp = req.send().await?;
268        let status = resp.status();
269        if status.is_success() {
270            Ok(())
271        } else {
272            Err(crate::types::error::Error::UnexpectedResponse(resp))
273        }
274    }
275
276    #[doc = "Remove conversation links\n\nRemoves one or more links to a conversation\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID (required)\n\n```rust,no_run\nasync fn example_conversations_remove_link() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    client\n        .conversations()\n        .remove_link(\n            \"some-string\",\n            &front_api::types::RemoveConversationLinkRequestBody {\n                link_ids: vec![\"some-string\".to_string()],\n            },\n        )\n        .await?;\n    Ok(())\n}\n```"]
277    #[tracing::instrument]
278    pub async fn remove_link<'a>(
279        &'a self,
280        conversation_id: &'a str,
281        body: &crate::types::RemoveConversationLinkRequestBody,
282    ) -> Result<(), crate::types::error::Error> {
283        let mut req = self.client.client.request(
284            http::Method::DELETE,
285            &format!(
286                "{}/{}",
287                self.client.base_url,
288                "conversations/{conversation_id}/links"
289                    .replace("{conversation_id}", conversation_id)
290            ),
291        );
292        req = req.bearer_auth(&self.client.token);
293        req = req.json(body);
294        let resp = req.send().await?;
295        let status = resp.status();
296        if status.is_success() {
297            Ok(())
298        } else {
299            Err(crate::types::error::Error::UnexpectedResponse(resp))
300        }
301    }
302
303    #[doc = "List conversation inboxes\n\nList the inboxes in which a conversation is \
304             listed.\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID \
305             (required)\n\n```rust,no_run\nasync fn example_conversations_list_inboxes() -> \
306             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let \
307             result: front_api::types::ListConversationInboxesResponse =\n        \
308             client.conversations().list_inboxes(\"some-string\").await?;\n    println!(\"{:?}\", \
309             result);\n    Ok(())\n}\n```"]
310    #[tracing::instrument]
311    pub async fn list_inboxes<'a>(
312        &'a self,
313        conversation_id: &'a str,
314    ) -> Result<crate::types::ListConversationInboxesResponse, crate::types::error::Error> {
315        let mut req = self.client.client.request(
316            http::Method::GET,
317            &format!(
318                "{}/{}",
319                self.client.base_url,
320                "conversations/{conversation_id}/inboxes"
321                    .replace("{conversation_id}", conversation_id)
322            ),
323        );
324        req = req.bearer_auth(&self.client.token);
325        let resp = req.send().await?;
326        let status = resp.status();
327        if status.is_success() {
328            let text = resp.text().await.unwrap_or_default();
329            serde_json::from_str(&text).map_err(|err| {
330                crate::types::error::Error::from_serde_error(
331                    format_serde_error::SerdeError::new(text.to_string(), err),
332                    status,
333                )
334            })
335        } else {
336            Err(crate::types::error::Error::UnexpectedResponse(resp))
337        }
338    }
339
340    #[doc = "List conversation followers\n\nList the teammates following a \
341             conversation.\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID \
342             (required)\n\n```rust,no_run\nasync fn example_conversations_list_followers() -> \
343             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let \
344             result: front_api::types::ListConversationFollowersResponse =\n        \
345             client.conversations().list_followers(\"some-string\").await?;\n    \
346             println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
347    #[tracing::instrument]
348    pub async fn list_followers<'a>(
349        &'a self,
350        conversation_id: &'a str,
351    ) -> Result<crate::types::ListConversationFollowersResponse, crate::types::error::Error> {
352        let mut req = self.client.client.request(
353            http::Method::GET,
354            &format!(
355                "{}/{}",
356                self.client.base_url,
357                "conversations/{conversation_id}/followers"
358                    .replace("{conversation_id}", conversation_id)
359            ),
360        );
361        req = req.bearer_auth(&self.client.token);
362        let resp = req.send().await?;
363        let status = resp.status();
364        if status.is_success() {
365            let text = resp.text().await.unwrap_or_default();
366            serde_json::from_str(&text).map_err(|err| {
367                crate::types::error::Error::from_serde_error(
368                    format_serde_error::SerdeError::new(text.to_string(), err),
369                    status,
370                )
371            })
372        } else {
373            Err(crate::types::error::Error::UnexpectedResponse(resp))
374        }
375    }
376
377    #[doc = "Add conversation followers\n\nAdds teammates to the list of followers of a conversation.\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID (required)\n\n```rust,no_run\nasync fn example_conversations_add_followers() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    client\n        .conversations()\n        .add_followers(\n            \"some-string\",\n            &front_api::types::AddConversationFollowersRequestBody {\n                teammate_ids: vec![\"some-string\".to_string()],\n            },\n        )\n        .await?;\n    Ok(())\n}\n```"]
378    #[tracing::instrument]
379    pub async fn add_followers<'a>(
380        &'a self,
381        conversation_id: &'a str,
382        body: &crate::types::AddConversationFollowersRequestBody,
383    ) -> Result<(), crate::types::error::Error> {
384        let mut req = self.client.client.request(
385            http::Method::POST,
386            &format!(
387                "{}/{}",
388                self.client.base_url,
389                "conversations/{conversation_id}/followers"
390                    .replace("{conversation_id}", conversation_id)
391            ),
392        );
393        req = req.bearer_auth(&self.client.token);
394        req = req.json(body);
395        let resp = req.send().await?;
396        let status = resp.status();
397        if status.is_success() {
398            Ok(())
399        } else {
400            Err(crate::types::error::Error::UnexpectedResponse(resp))
401        }
402    }
403
404    #[doc = "Delete conversation followers\n\nRemoves teammates from the list of followers of a \
405             conversation.\n\n**Parameters:**\n\n- `conversation_id: &'astr`: The conversation ID \
406             (required)\n\n```rust,no_run\nasync fn example_conversations_delete_followers() -> \
407             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    \
408             client\n        .conversations()\n        .delete_followers(\n            \
409             \"some-string\",\n            \
410             &front_api::types::DeleteConversationFollowersRequestBody {\n                \
411             teammate_ids: vec![\"some-string\".to_string()],\n            },\n        )\n        \
412             .await?;\n    Ok(())\n}\n```"]
413    #[tracing::instrument]
414    pub async fn delete_followers<'a>(
415        &'a self,
416        conversation_id: &'a str,
417        body: &crate::types::DeleteConversationFollowersRequestBody,
418    ) -> Result<(), crate::types::error::Error> {
419        let mut req = self.client.client.request(
420            http::Method::DELETE,
421            &format!(
422                "{}/{}",
423                self.client.base_url,
424                "conversations/{conversation_id}/followers"
425                    .replace("{conversation_id}", conversation_id)
426            ),
427        );
428        req = req.bearer_auth(&self.client.token);
429        req = req.json(body);
430        let resp = req.send().await?;
431        let status = resp.status();
432        if status.is_success() {
433            Ok(())
434        } else {
435            Err(crate::types::error::Error::UnexpectedResponse(resp))
436        }
437    }
438
439    #[doc = "List conversation messages\n\nList the messages in a conversation in reverse \
440             chronological order (newest first).\n\n**Parameters:**\n\n- `conversation_id: \
441             &'astr`: The conversation ID (required)\n- `limit: Option<i64>`: Max number of \
442             results per page\n- `page_token: Option<String>`: Token to use to request the next \
443             page\n\n```rust,no_run\nasync fn example_conversations_list_messages() -> \
444             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let \
445             result: front_api::types::ListConversationMessagesResponse = client\n        \
446             .conversations()\n        .list_messages(\n            \"some-string\",\n            \
447             Some(4 as i64),\n            Some(\"some-string\".to_string()),\n        )\n        \
448             .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
449    #[tracing::instrument]
450    pub async fn list_messages<'a>(
451        &'a self,
452        conversation_id: &'a str,
453        limit: Option<i64>,
454        page_token: Option<String>,
455    ) -> Result<crate::types::ListConversationMessagesResponse, crate::types::error::Error> {
456        let mut req = self.client.client.request(
457            http::Method::GET,
458            &format!(
459                "{}/{}",
460                self.client.base_url,
461                "conversations/{conversation_id}/messages"
462                    .replace("{conversation_id}", conversation_id)
463            ),
464        );
465        req = req.bearer_auth(&self.client.token);
466        let mut query_params = Vec::new();
467        if let Some(p) = limit {
468            query_params.push(("limit", format!("{}", p)));
469        }
470
471        if let Some(p) = page_token {
472            query_params.push(("page_token", p));
473        }
474
475        req = req.query(&query_params);
476        let resp = req.send().await?;
477        let status = resp.status();
478        if status.is_success() {
479            let text = resp.text().await.unwrap_or_default();
480            serde_json::from_str(&text).map_err(|err| {
481                crate::types::error::Error::from_serde_error(
482                    format_serde_error::SerdeError::new(text.to_string(), err),
483                    status,
484                )
485            })
486        } else {
487            Err(crate::types::error::Error::UnexpectedResponse(resp))
488        }
489    }
490
491    #[doc = "List conversation events\n\nList the events that occured for a conversation in \
492             reverse chronological order (newest first).\n\n**Parameters:**\n\n- `conversation_id: \
493             &'astr`: The conversation ID (required)\n- `limit: Option<i64>`: Max number of \
494             results per page\n- `page_token: Option<String>`: Token to use to request the next \
495             page\n\n```rust,no_run\nasync fn example_conversations_list_events() -> \
496             anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let \
497             result: front_api::types::ListConversationEventsResponse = client\n        \
498             .conversations()\n        .list_events(\n            \"some-string\",\n            \
499             Some(4 as i64),\n            Some(\"some-string\".to_string()),\n        )\n        \
500             .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
501    #[tracing::instrument]
502    pub async fn list_events<'a>(
503        &'a self,
504        conversation_id: &'a str,
505        limit: Option<i64>,
506        page_token: Option<String>,
507    ) -> Result<crate::types::ListConversationEventsResponse, crate::types::error::Error> {
508        let mut req = self.client.client.request(
509            http::Method::GET,
510            &format!(
511                "{}/{}",
512                self.client.base_url,
513                "conversations/{conversation_id}/events"
514                    .replace("{conversation_id}", conversation_id)
515            ),
516        );
517        req = req.bearer_auth(&self.client.token);
518        let mut query_params = Vec::new();
519        if let Some(p) = limit {
520            query_params.push(("limit", format!("{}", p)));
521        }
522
523        if let Some(p) = page_token {
524            query_params.push(("page_token", p));
525        }
526
527        req = req.query(&query_params);
528        let resp = req.send().await?;
529        let status = resp.status();
530        if status.is_success() {
531            let text = resp.text().await.unwrap_or_default();
532            serde_json::from_str(&text).map_err(|err| {
533                crate::types::error::Error::from_serde_error(
534                    format_serde_error::SerdeError::new(text.to_string(), err),
535                    status,
536                )
537            })
538        } else {
539            Err(crate::types::error::Error::UnexpectedResponse(resp))
540        }
541    }
542
543    #[doc = "Update conversation reminders\n\nSnooze or unsnooze a conversation for the provided \
544             user.\nFor private conversations, reminders can only be created and edited through \
545             the API for teammates that own the conversation.\nFor shared conversations, reminders \
546             created and edited through the API are shared for all teammates within the shared \
547             inbox(es) that the conversation belongs to.\n\n\n**Parameters:**\n\n- \
548             `conversation_id: &'astr`: The conversation ID (required)\n\n```rust,no_run\nasync fn \
549             example_conversations_update_reminders() -> anyhow::Result<()> {\n    let client = \
550             front_api::Client::new_from_env();\n    client\n        .conversations()\n        \
551             .update_reminders(\n            \"some-string\",\n            \
552             &serde_json::Value::String(\"some-string\".to_string()),\n        )\n        \
553             .await?;\n    Ok(())\n}\n```"]
554    #[tracing::instrument]
555    pub async fn update_reminders<'a>(
556        &'a self,
557        conversation_id: &'a str,
558        body: &crate::types::UpdateConversationReminders,
559    ) -> Result<(), crate::types::error::Error> {
560        let mut req = self.client.client.request(
561            http::Method::PATCH,
562            &format!(
563                "{}/{}",
564                self.client.base_url,
565                "conversations/{conversation_id}/reminders"
566                    .replace("{conversation_id}", conversation_id)
567            ),
568        );
569        req = req.bearer_auth(&self.client.token);
570        req = req.json(body);
571        let resp = req.send().await?;
572        let status = resp.status();
573        if status.is_success() {
574            Ok(())
575        } else {
576            Err(crate::types::error::Error::UnexpectedResponse(resp))
577        }
578    }
579
580    #[doc = "Search conversations\n\nSearch for conversations. Response will include a count of total matches and an array of conversations in descending order by last activity.\nSee the [search syntax documentation](https://dev.frontapp.com/docs/search-1) for usage examples.\n> ⚠\u{fe0f} Deprecated field included\n>\n> This endpoint returns a deprecated `last_message` field in the top-level conversation bodies listed. Please use the\n> `_links.related.last_message` field instead.\n\n\n**Parameters:**\n\n- `limit: Option<i64>`: Max number of results per page\n- `page_token: Option<String>`: Token to use to request the next page\n- `query: &'astr`: Search query string. See available Conversation Search Parameters below (required)\n\n```rust,no_run\nasync fn example_conversations_search() -> anyhow::Result<()> {\n    let client = front_api::Client::new_from_env();\n    let result: front_api::types::SearchConversationsResponse = client\n        .conversations()\n        .search(\n            Some(4 as i64),\n            Some(\"some-string\".to_string()),\n            \"some-string\",\n        )\n        .await?;\n    println!(\"{:?}\", result);\n    Ok(())\n}\n```"]
581    #[tracing::instrument]
582    pub async fn search<'a>(
583        &'a self,
584        limit: Option<i64>,
585        page_token: Option<String>,
586        query: &'a str,
587    ) -> Result<crate::types::SearchConversationsResponse, crate::types::error::Error> {
588        let mut req = self.client.client.request(
589            http::Method::GET,
590            &format!(
591                "{}/{}",
592                self.client.base_url,
593                "conversations/search/{query}".replace("{query}", query)
594            ),
595        );
596        req = req.bearer_auth(&self.client.token);
597        let mut query_params = Vec::new();
598        if let Some(p) = limit {
599            query_params.push(("limit", format!("{}", p)));
600        }
601
602        if let Some(p) = page_token {
603            query_params.push(("page_token", p));
604        }
605
606        req = req.query(&query_params);
607        let resp = req.send().await?;
608        let status = resp.status();
609        if status.is_success() {
610            let text = resp.text().await.unwrap_or_default();
611            serde_json::from_str(&text).map_err(|err| {
612                crate::types::error::Error::from_serde_error(
613                    format_serde_error::SerdeError::new(text.to_string(), err),
614                    status,
615                )
616            })
617        } else {
618            Err(crate::types::error::Error::UnexpectedResponse(resp))
619        }
620    }
621}