Skip to main content

spatio_sdk/apis/
direct_messages_api.rs

1/*
2 * SpatioAPI
3 *
4 * The REST API that owns every resource in your Spatio workspace: notes, sheets, slides, tasks, calendar events, mail, chat, files, and contacts. SpatioMCP wraps this API; Spatio Desktop reads from it. You can call it directly from your own code.  All requests must be authenticated with a Personal Access Token (`Authorization: Bearer pat_...`) or an OAuth 2.1 access token, and use HTTPS.  Official SDKs (MIT, generated from this spec on every release):  - TypeScript: https://github.com/spatio-labs/spatio-ts (`npm install @spatio-labs/spatio-ts`) - Python: https://github.com/spatio-labs/spatio-py (`pip install spatio-sdk`) - Go: https://github.com/spatio-labs/spatio-go (`go get github.com/spatio-labs/spatio-go`)  This specification is generated from the platform-service Go source on every push to `main`. The spec, not hand-written documentation, is the source of truth: server stubs and SDKs are generated from it, and any drift between the spec and the running service fails CI. 
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: hello@spatio.app
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`add_dm_reaction`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddDmReactionError {
22    Status400(models::ApiError),
23    Status401(models::ApiError),
24    UnknownValue(serde_json::Value),
25}
26
27/// struct for typed errors of method [`attach_to_dm_message`]
28#[derive(Debug, Clone, Serialize, Deserialize)]
29#[serde(untagged)]
30pub enum AttachToDmMessageError {
31    Status400(models::ApiError),
32    Status401(models::ApiError),
33    UnknownValue(serde_json::Value),
34}
35
36/// struct for typed errors of method [`execute_dm_action`]
37#[derive(Debug, Clone, Serialize, Deserialize)]
38#[serde(untagged)]
39pub enum ExecuteDmActionError {
40    Status400(models::ApiError),
41    Status401(models::ApiError),
42    UnknownValue(serde_json::Value),
43}
44
45/// struct for typed errors of method [`forward_dm_message`]
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(untagged)]
48pub enum ForwardDmMessageError {
49    Status400(models::ApiError),
50    Status401(models::ApiError),
51    UnknownValue(serde_json::Value),
52}
53
54/// struct for typed errors of method [`get_dm_user`]
55#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum GetDmUserError {
58    Status401(models::ApiError),
59    Status404(models::ApiError),
60    UnknownValue(serde_json::Value),
61}
62
63/// struct for typed errors of method [`list_direct_conversations_enriched`]
64#[derive(Debug, Clone, Serialize, Deserialize)]
65#[serde(untagged)]
66pub enum ListDirectConversationsEnrichedError {
67    Status401(models::ApiError),
68    UnknownValue(serde_json::Value),
69}
70
71/// struct for typed errors of method [`list_direct_message_conversations`]
72#[derive(Debug, Clone, Serialize, Deserialize)]
73#[serde(untagged)]
74pub enum ListDirectMessageConversationsError {
75    Status401(models::ApiError),
76    UnknownValue(serde_json::Value),
77}
78
79/// struct for typed errors of method [`list_direct_messages`]
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum ListDirectMessagesError {
83    Status400(models::ApiError),
84    Status401(models::ApiError),
85    UnknownValue(serde_json::Value),
86}
87
88/// struct for typed errors of method [`list_dm_actions`]
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum ListDmActionsError {
92    Status401(models::ApiError),
93    UnknownValue(serde_json::Value),
94}
95
96/// struct for typed errors of method [`list_dm_pinned_messages`]
97#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum ListDmPinnedMessagesError {
100    Status401(models::ApiError),
101    UnknownValue(serde_json::Value),
102}
103
104/// struct for typed errors of method [`list_dm_thread_replies`]
105#[derive(Debug, Clone, Serialize, Deserialize)]
106#[serde(untagged)]
107pub enum ListDmThreadRepliesError {
108    Status401(models::ApiError),
109    UnknownValue(serde_json::Value),
110}
111
112/// struct for typed errors of method [`list_dm_users`]
113#[derive(Debug, Clone, Serialize, Deserialize)]
114#[serde(untagged)]
115pub enum ListDmUsersError {
116    Status401(models::ApiError),
117    UnknownValue(serde_json::Value),
118}
119
120/// struct for typed errors of method [`mark_dm_read`]
121#[derive(Debug, Clone, Serialize, Deserialize)]
122#[serde(untagged)]
123pub enum MarkDmReadError {
124    Status400(models::ApiError),
125    Status401(models::ApiError),
126    UnknownValue(serde_json::Value),
127}
128
129/// struct for typed errors of method [`mute_dm`]
130#[derive(Debug, Clone, Serialize, Deserialize)]
131#[serde(untagged)]
132pub enum MuteDmError {
133    Status400(models::ApiError),
134    Status401(models::ApiError),
135    UnknownValue(serde_json::Value),
136}
137
138/// struct for typed errors of method [`pin_dm_conversation`]
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum PinDmConversationError {
142    Status401(models::ApiError),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`pin_dm_message`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum PinDmMessageError {
150    Status401(models::ApiError),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method [`post_dm_thread_reply`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum PostDmThreadReplyError {
158    Status400(models::ApiError),
159    Status401(models::ApiError),
160    UnknownValue(serde_json::Value),
161}
162
163/// struct for typed errors of method [`remove_dm_reaction`]
164#[derive(Debug, Clone, Serialize, Deserialize)]
165#[serde(untagged)]
166pub enum RemoveDmReactionError {
167    Status401(models::ApiError),
168    UnknownValue(serde_json::Value),
169}
170
171/// struct for typed errors of method [`search_direct_messages`]
172#[derive(Debug, Clone, Serialize, Deserialize)]
173#[serde(untagged)]
174pub enum SearchDirectMessagesError {
175    Status400(models::ApiError),
176    Status401(models::ApiError),
177    UnknownValue(serde_json::Value),
178}
179
180/// struct for typed errors of method [`send_direct_message`]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum SendDirectMessageError {
184    Status400(models::ApiError),
185    Status401(models::ApiError),
186    UnknownValue(serde_json::Value),
187}
188
189/// struct for typed errors of method [`set_dm_draft`]
190#[derive(Debug, Clone, Serialize, Deserialize)]
191#[serde(untagged)]
192pub enum SetDmDraftError {
193    Status400(models::ApiError),
194    Status401(models::ApiError),
195    UnknownValue(serde_json::Value),
196}
197
198/// struct for typed errors of method [`unpin_dm_conversation`]
199#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(untagged)]
201pub enum UnpinDmConversationError {
202    Status401(models::ApiError),
203    UnknownValue(serde_json::Value),
204}
205
206/// struct for typed errors of method [`unpin_dm_message`]
207#[derive(Debug, Clone, Serialize, Deserialize)]
208#[serde(untagged)]
209pub enum UnpinDmMessageError {
210    Status401(models::ApiError),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`workspace_execute_dm_action`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum WorkspaceExecuteDmActionError {
218    Status401(models::ApiError),
219    Status403(models::ApiError),
220    UnknownValue(serde_json::Value),
221}
222
223/// struct for typed errors of method [`workspace_get_dm_user`]
224#[derive(Debug, Clone, Serialize, Deserialize)]
225#[serde(untagged)]
226pub enum WorkspaceGetDmUserError {
227    Status401(models::ApiError),
228    Status403(models::ApiError),
229    UnknownValue(serde_json::Value),
230}
231
232/// struct for typed errors of method [`workspace_list_direct_messages`]
233#[derive(Debug, Clone, Serialize, Deserialize)]
234#[serde(untagged)]
235pub enum WorkspaceListDirectMessagesError {
236    Status401(models::ApiError),
237    Status403(models::ApiError),
238    UnknownValue(serde_json::Value),
239}
240
241/// struct for typed errors of method [`workspace_list_dm_actions`]
242#[derive(Debug, Clone, Serialize, Deserialize)]
243#[serde(untagged)]
244pub enum WorkspaceListDmActionsError {
245    Status401(models::ApiError),
246    Status403(models::ApiError),
247    UnknownValue(serde_json::Value),
248}
249
250/// struct for typed errors of method [`workspace_list_dm_conversations`]
251#[derive(Debug, Clone, Serialize, Deserialize)]
252#[serde(untagged)]
253pub enum WorkspaceListDmConversationsError {
254    Status401(models::ApiError),
255    Status403(models::ApiError),
256    UnknownValue(serde_json::Value),
257}
258
259/// struct for typed errors of method [`workspace_list_dm_messages`]
260#[derive(Debug, Clone, Serialize, Deserialize)]
261#[serde(untagged)]
262pub enum WorkspaceListDmMessagesError {
263    Status401(models::ApiError),
264    Status403(models::ApiError),
265    UnknownValue(serde_json::Value),
266}
267
268/// struct for typed errors of method [`workspace_list_dm_users`]
269#[derive(Debug, Clone, Serialize, Deserialize)]
270#[serde(untagged)]
271pub enum WorkspaceListDmUsersError {
272    Status401(models::ApiError),
273    Status403(models::ApiError),
274    UnknownValue(serde_json::Value),
275}
276
277/// struct for typed errors of method [`workspace_send_direct_message`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum WorkspaceSendDirectMessageError {
281    Status401(models::ApiError),
282    Status403(models::ApiError),
283    UnknownValue(serde_json::Value),
284}
285
286
287pub async fn add_dm_reaction(configuration: &configuration::Configuration, message_id: &str, dm_reaction_request: models::DmReactionRequest) -> Result<models::DmReactionResponse, Error<AddDmReactionError>> {
288    // add a prefix to parameters to efficiently prevent name collisions
289    let p_path_message_id = message_id;
290    let p_body_dm_reaction_request = dm_reaction_request;
291
292    let uri_str = format!("{}/v1/direct-messages/messages/{messageId}/reactions", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
293    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
294
295    if let Some(ref user_agent) = configuration.user_agent {
296        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297    }
298    if let Some(ref token) = configuration.bearer_access_token {
299        req_builder = req_builder.bearer_auth(token.to_owned());
300    };
301    req_builder = req_builder.json(&p_body_dm_reaction_request);
302
303    let req = req_builder.build()?;
304    let resp = configuration.client.execute(req).await?;
305
306    let status = resp.status();
307    let content_type = resp
308        .headers()
309        .get("content-type")
310        .and_then(|v| v.to_str().ok())
311        .unwrap_or("application/octet-stream");
312    let content_type = super::ContentType::from(content_type);
313
314    if !status.is_client_error() && !status.is_server_error() {
315        let content = resp.text().await?;
316        match content_type {
317            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
318            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmReactionResponse`"))),
319            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmReactionResponse`")))),
320        }
321    } else {
322        let content = resp.text().await?;
323        let entity: Option<AddDmReactionError> = serde_json::from_str(&content).ok();
324        Err(Error::ResponseError(ResponseContent { status, content, entity }))
325    }
326}
327
328pub async fn attach_to_dm_message(configuration: &configuration::Configuration, message_id: &str, dm_attach_request: models::DmAttachRequest) -> Result<models::DmMessageEnvelope, Error<AttachToDmMessageError>> {
329    // add a prefix to parameters to efficiently prevent name collisions
330    let p_path_message_id = message_id;
331    let p_body_dm_attach_request = dm_attach_request;
332
333    let uri_str = format!("{}/v1/direct-messages/messages/{messageId}/attachments", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
334    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
335
336    if let Some(ref user_agent) = configuration.user_agent {
337        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
338    }
339    if let Some(ref token) = configuration.bearer_access_token {
340        req_builder = req_builder.bearer_auth(token.to_owned());
341    };
342    req_builder = req_builder.json(&p_body_dm_attach_request);
343
344    let req = req_builder.build()?;
345    let resp = configuration.client.execute(req).await?;
346
347    let status = resp.status();
348    let content_type = resp
349        .headers()
350        .get("content-type")
351        .and_then(|v| v.to_str().ok())
352        .unwrap_or("application/octet-stream");
353    let content_type = super::ContentType::from(content_type);
354
355    if !status.is_client_error() && !status.is_server_error() {
356        let content = resp.text().await?;
357        match content_type {
358            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
359            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmMessageEnvelope`"))),
360            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmMessageEnvelope`")))),
361        }
362    } else {
363        let content = resp.text().await?;
364        let entity: Option<AttachToDmMessageError> = serde_json::from_str(&content).ok();
365        Err(Error::ResponseError(ResponseContent { status, content, entity }))
366    }
367}
368
369pub async fn execute_dm_action(configuration: &configuration::Configuration, execute_chat_action_request: models::ExecuteChatActionRequest) -> Result<models::ExecuteChatActionResponse, Error<ExecuteDmActionError>> {
370    // add a prefix to parameters to efficiently prevent name collisions
371    let p_body_execute_chat_action_request = execute_chat_action_request;
372
373    let uri_str = format!("{}/v1/direct-messages/execute", configuration.base_path);
374    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
375
376    if let Some(ref user_agent) = configuration.user_agent {
377        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
378    }
379    if let Some(ref token) = configuration.bearer_access_token {
380        req_builder = req_builder.bearer_auth(token.to_owned());
381    };
382    req_builder = req_builder.json(&p_body_execute_chat_action_request);
383
384    let req = req_builder.build()?;
385    let resp = configuration.client.execute(req).await?;
386
387    let status = resp.status();
388    let content_type = resp
389        .headers()
390        .get("content-type")
391        .and_then(|v| v.to_str().ok())
392        .unwrap_or("application/octet-stream");
393    let content_type = super::ContentType::from(content_type);
394
395    if !status.is_client_error() && !status.is_server_error() {
396        let content = resp.text().await?;
397        match content_type {
398            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
399            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ExecuteChatActionResponse`"))),
400            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ExecuteChatActionResponse`")))),
401        }
402    } else {
403        let content = resp.text().await?;
404        let entity: Option<ExecuteDmActionError> = serde_json::from_str(&content).ok();
405        Err(Error::ResponseError(ResponseContent { status, content, entity }))
406    }
407}
408
409pub async fn forward_dm_message(configuration: &configuration::Configuration, message_id: &str, dm_forward_request: models::DmForwardRequest) -> Result<models::DmMessageEnvelope, Error<ForwardDmMessageError>> {
410    // add a prefix to parameters to efficiently prevent name collisions
411    let p_path_message_id = message_id;
412    let p_body_dm_forward_request = dm_forward_request;
413
414    let uri_str = format!("{}/v1/direct-messages/messages/{messageId}/forward", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
415    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
416
417    if let Some(ref user_agent) = configuration.user_agent {
418        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
419    }
420    if let Some(ref token) = configuration.bearer_access_token {
421        req_builder = req_builder.bearer_auth(token.to_owned());
422    };
423    req_builder = req_builder.json(&p_body_dm_forward_request);
424
425    let req = req_builder.build()?;
426    let resp = configuration.client.execute(req).await?;
427
428    let status = resp.status();
429    let content_type = resp
430        .headers()
431        .get("content-type")
432        .and_then(|v| v.to_str().ok())
433        .unwrap_or("application/octet-stream");
434    let content_type = super::ContentType::from(content_type);
435
436    if !status.is_client_error() && !status.is_server_error() {
437        let content = resp.text().await?;
438        match content_type {
439            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
440            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmMessageEnvelope`"))),
441            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmMessageEnvelope`")))),
442        }
443    } else {
444        let content = resp.text().await?;
445        let entity: Option<ForwardDmMessageError> = serde_json::from_str(&content).ok();
446        Err(Error::ResponseError(ResponseContent { status, content, entity }))
447    }
448}
449
450pub async fn get_dm_user(configuration: &configuration::Configuration, id: &str, account_id: Option<&str>) -> Result<models::GetChatUserResponse, Error<GetDmUserError>> {
451    // add a prefix to parameters to efficiently prevent name collisions
452    let p_path_id = id;
453    let p_query_account_id = account_id;
454
455    let uri_str = format!("{}/v1/direct-messages/users/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
456    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
457
458    if let Some(ref param_value) = p_query_account_id {
459        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
460    }
461    if let Some(ref user_agent) = configuration.user_agent {
462        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
463    }
464    if let Some(ref token) = configuration.bearer_access_token {
465        req_builder = req_builder.bearer_auth(token.to_owned());
466    };
467
468    let req = req_builder.build()?;
469    let resp = configuration.client.execute(req).await?;
470
471    let status = resp.status();
472    let content_type = resp
473        .headers()
474        .get("content-type")
475        .and_then(|v| v.to_str().ok())
476        .unwrap_or("application/octet-stream");
477    let content_type = super::ContentType::from(content_type);
478
479    if !status.is_client_error() && !status.is_server_error() {
480        let content = resp.text().await?;
481        match content_type {
482            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
483            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetChatUserResponse`"))),
484            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::GetChatUserResponse`")))),
485        }
486    } else {
487        let content = resp.text().await?;
488        let entity: Option<GetDmUserError> = serde_json::from_str(&content).ok();
489        Err(Error::ResponseError(ResponseContent { status, content, entity }))
490    }
491}
492
493/// Native fast-path. Returns conversations augmented with the DM-feature state (unread counts, pinned/muted flags, saved drafts) the renderer's DM UI consumes. The shape is provider-specific and treated as opaque. 
494pub async fn list_direct_conversations_enriched(configuration: &configuration::Configuration, account_id: Option<&str>, x_workspace_id: Option<&str>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListDirectConversationsEnrichedError>> {
495    // add a prefix to parameters to efficiently prevent name collisions
496    let p_query_account_id = account_id;
497    let p_header_x_workspace_id = x_workspace_id;
498
499    let uri_str = format!("{}/v1/direct-messages/conversations", configuration.base_path);
500    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
501
502    if let Some(ref param_value) = p_query_account_id {
503        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
504    }
505    if let Some(ref user_agent) = configuration.user_agent {
506        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
507    }
508    if let Some(param_value) = p_header_x_workspace_id {
509        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
510    }
511    if let Some(ref token) = configuration.bearer_access_token {
512        req_builder = req_builder.bearer_auth(token.to_owned());
513    };
514
515    let req = req_builder.build()?;
516    let resp = configuration.client.execute(req).await?;
517
518    let status = resp.status();
519    let content_type = resp
520        .headers()
521        .get("content-type")
522        .and_then(|v| v.to_str().ok())
523        .unwrap_or("application/octet-stream");
524    let content_type = super::ContentType::from(content_type);
525
526    if !status.is_client_error() && !status.is_server_error() {
527        let content = resp.text().await?;
528        match content_type {
529            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
530            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
531            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
532        }
533    } else {
534        let content = resp.text().await?;
535        let entity: Option<ListDirectConversationsEnrichedError> = serde_json::from_str(&content).ok();
536        Err(Error::ResponseError(ResponseContent { status, content, entity }))
537    }
538}
539
540/// Returns DM-type conversations only (`type: im | mpim`). Channel-type conversations are surfaced via `/v1/channels`. 
541pub async fn list_direct_message_conversations(configuration: &configuration::Configuration, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, limit: Option<i32>, cursor: Option<&str>, include_archived: Option<bool>) -> Result<models::ListChannelsResponse, Error<ListDirectMessageConversationsError>> {
542    // add a prefix to parameters to efficiently prevent name collisions
543    let p_query_account_ids = account_ids;
544    let p_query_providers = providers;
545    let p_header_x_workspace_id = x_workspace_id;
546    let p_query_limit = limit;
547    let p_query_cursor = cursor;
548    let p_query_include_archived = include_archived;
549
550    let uri_str = format!("{}/v1/direct-messages", configuration.base_path);
551    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
552
553    if let Some(ref param_value) = p_query_account_ids {
554        req_builder = match "multi" {
555            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
556            _ => req_builder.query(&[("accountIds", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
557        };
558    }
559    if let Some(ref param_value) = p_query_providers {
560        req_builder = match "multi" {
561            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
562            _ => req_builder.query(&[("providers", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
563        };
564    }
565    if let Some(ref param_value) = p_query_limit {
566        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
567    }
568    if let Some(ref param_value) = p_query_cursor {
569        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
570    }
571    if let Some(ref param_value) = p_query_include_archived {
572        req_builder = req_builder.query(&[("includeArchived", &param_value.to_string())]);
573    }
574    if let Some(ref user_agent) = configuration.user_agent {
575        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
576    }
577    if let Some(param_value) = p_header_x_workspace_id {
578        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
579    }
580    if let Some(ref token) = configuration.bearer_access_token {
581        req_builder = req_builder.bearer_auth(token.to_owned());
582    };
583
584    let req = req_builder.build()?;
585    let resp = configuration.client.execute(req).await?;
586
587    let status = resp.status();
588    let content_type = resp
589        .headers()
590        .get("content-type")
591        .and_then(|v| v.to_str().ok())
592        .unwrap_or("application/octet-stream");
593    let content_type = super::ContentType::from(content_type);
594
595    if !status.is_client_error() && !status.is_server_error() {
596        let content = resp.text().await?;
597        match content_type {
598            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
599            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListChannelsResponse`"))),
600            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListChannelsResponse`")))),
601        }
602    } else {
603        let content = resp.text().await?;
604        let entity: Option<ListDirectMessageConversationsError> = serde_json::from_str(&content).ok();
605        Err(Error::ResponseError(ResponseContent { status, content, entity }))
606    }
607}
608
609pub async fn list_direct_messages(configuration: &configuration::Configuration, channel: &str, account_id: Option<&str>, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, limit: Option<i32>, cursor: Option<&str>, oldest_first: Option<bool>) -> Result<models::ListMessagesResponse, Error<ListDirectMessagesError>> {
610    // add a prefix to parameters to efficiently prevent name collisions
611    let p_query_channel = channel;
612    let p_query_account_id = account_id;
613    let p_query_account_ids = account_ids;
614    let p_query_providers = providers;
615    let p_header_x_workspace_id = x_workspace_id;
616    let p_query_limit = limit;
617    let p_query_cursor = cursor;
618    let p_query_oldest_first = oldest_first;
619
620    let uri_str = format!("{}/v1/direct-messages/messages", configuration.base_path);
621    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
622
623    req_builder = req_builder.query(&[("channel", &p_query_channel.to_string())]);
624    if let Some(ref param_value) = p_query_account_id {
625        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
626    }
627    if let Some(ref param_value) = p_query_account_ids {
628        req_builder = match "multi" {
629            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
630            _ => req_builder.query(&[("accountIds", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
631        };
632    }
633    if let Some(ref param_value) = p_query_providers {
634        req_builder = match "multi" {
635            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
636            _ => req_builder.query(&[("providers", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
637        };
638    }
639    if let Some(ref param_value) = p_query_limit {
640        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
641    }
642    if let Some(ref param_value) = p_query_cursor {
643        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
644    }
645    if let Some(ref param_value) = p_query_oldest_first {
646        req_builder = req_builder.query(&[("oldestFirst", &param_value.to_string())]);
647    }
648    if let Some(ref user_agent) = configuration.user_agent {
649        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
650    }
651    if let Some(param_value) = p_header_x_workspace_id {
652        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
653    }
654    if let Some(ref token) = configuration.bearer_access_token {
655        req_builder = req_builder.bearer_auth(token.to_owned());
656    };
657
658    let req = req_builder.build()?;
659    let resp = configuration.client.execute(req).await?;
660
661    let status = resp.status();
662    let content_type = resp
663        .headers()
664        .get("content-type")
665        .and_then(|v| v.to_str().ok())
666        .unwrap_or("application/octet-stream");
667    let content_type = super::ContentType::from(content_type);
668
669    if !status.is_client_error() && !status.is_server_error() {
670        let content = resp.text().await?;
671        match content_type {
672            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
673            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListMessagesResponse`"))),
674            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListMessagesResponse`")))),
675        }
676    } else {
677        let content = resp.text().await?;
678        let entity: Option<ListDirectMessagesError> = serde_json::from_str(&content).ok();
679        Err(Error::ResponseError(ResponseContent { status, content, entity }))
680    }
681}
682
683pub async fn list_dm_actions(configuration: &configuration::Configuration, ) -> Result<models::ChatActionsList, Error<ListDmActionsError>> {
684
685    let uri_str = format!("{}/v1/direct-messages/actions", configuration.base_path);
686    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
687
688    if let Some(ref user_agent) = configuration.user_agent {
689        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
690    }
691    if let Some(ref token) = configuration.bearer_access_token {
692        req_builder = req_builder.bearer_auth(token.to_owned());
693    };
694
695    let req = req_builder.build()?;
696    let resp = configuration.client.execute(req).await?;
697
698    let status = resp.status();
699    let content_type = resp
700        .headers()
701        .get("content-type")
702        .and_then(|v| v.to_str().ok())
703        .unwrap_or("application/octet-stream");
704    let content_type = super::ContentType::from(content_type);
705
706    if !status.is_client_error() && !status.is_server_error() {
707        let content = resp.text().await?;
708        match content_type {
709            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
710            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ChatActionsList`"))),
711            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ChatActionsList`")))),
712        }
713    } else {
714        let content = resp.text().await?;
715        let entity: Option<ListDmActionsError> = serde_json::from_str(&content).ok();
716        Err(Error::ResponseError(ResponseContent { status, content, entity }))
717    }
718}
719
720pub async fn list_dm_pinned_messages(configuration: &configuration::Configuration, dm_id: &str, account_id: Option<&str>) -> Result<models::DmPinnedList, Error<ListDmPinnedMessagesError>> {
721    // add a prefix to parameters to efficiently prevent name collisions
722    let p_path_dm_id = dm_id;
723    let p_query_account_id = account_id;
724
725    let uri_str = format!("{}/v1/direct-messages/{dmId}/pinned", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
726    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
727
728    if let Some(ref param_value) = p_query_account_id {
729        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
730    }
731    if let Some(ref user_agent) = configuration.user_agent {
732        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
733    }
734    if let Some(ref token) = configuration.bearer_access_token {
735        req_builder = req_builder.bearer_auth(token.to_owned());
736    };
737
738    let req = req_builder.build()?;
739    let resp = configuration.client.execute(req).await?;
740
741    let status = resp.status();
742    let content_type = resp
743        .headers()
744        .get("content-type")
745        .and_then(|v| v.to_str().ok())
746        .unwrap_or("application/octet-stream");
747    let content_type = super::ContentType::from(content_type);
748
749    if !status.is_client_error() && !status.is_server_error() {
750        let content = resp.text().await?;
751        match content_type {
752            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
753            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmPinnedList`"))),
754            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmPinnedList`")))),
755        }
756    } else {
757        let content = resp.text().await?;
758        let entity: Option<ListDmPinnedMessagesError> = serde_json::from_str(&content).ok();
759        Err(Error::ResponseError(ResponseContent { status, content, entity }))
760    }
761}
762
763pub async fn list_dm_thread_replies(configuration: &configuration::Configuration, dm_id: &str, message_id: &str, account_id: Option<&str>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListDmThreadRepliesError>> {
764    // add a prefix to parameters to efficiently prevent name collisions
765    let p_path_dm_id = dm_id;
766    let p_path_message_id = message_id;
767    let p_query_account_id = account_id;
768
769    let uri_str = format!("{}/v1/direct-messages/{dmId}/messages/{messageId}/replies", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id), messageId=crate::apis::urlencode(p_path_message_id));
770    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
771
772    if let Some(ref param_value) = p_query_account_id {
773        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
774    }
775    if let Some(ref user_agent) = configuration.user_agent {
776        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
777    }
778    if let Some(ref token) = configuration.bearer_access_token {
779        req_builder = req_builder.bearer_auth(token.to_owned());
780    };
781
782    let req = req_builder.build()?;
783    let resp = configuration.client.execute(req).await?;
784
785    let status = resp.status();
786    let content_type = resp
787        .headers()
788        .get("content-type")
789        .and_then(|v| v.to_str().ok())
790        .unwrap_or("application/octet-stream");
791    let content_type = super::ContentType::from(content_type);
792
793    if !status.is_client_error() && !status.is_server_error() {
794        let content = resp.text().await?;
795        match content_type {
796            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
797            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
798            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
799        }
800    } else {
801        let content = resp.text().await?;
802        let entity: Option<ListDmThreadRepliesError> = serde_json::from_str(&content).ok();
803        Err(Error::ResponseError(ResponseContent { status, content, entity }))
804    }
805}
806
807pub async fn list_dm_users(configuration: &configuration::Configuration, account_ids: Option<Vec<String>>, providers: Option<Vec<String>>, x_workspace_id: Option<&str>, limit: Option<i32>, cursor: Option<&str>) -> Result<models::ListChatUsersResponse, Error<ListDmUsersError>> {
808    // add a prefix to parameters to efficiently prevent name collisions
809    let p_query_account_ids = account_ids;
810    let p_query_providers = providers;
811    let p_header_x_workspace_id = x_workspace_id;
812    let p_query_limit = limit;
813    let p_query_cursor = cursor;
814
815    let uri_str = format!("{}/v1/direct-messages/users", configuration.base_path);
816    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
817
818    if let Some(ref param_value) = p_query_account_ids {
819        req_builder = match "multi" {
820            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("accountIds".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
821            _ => req_builder.query(&[("accountIds", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
822        };
823    }
824    if let Some(ref param_value) = p_query_providers {
825        req_builder = match "multi" {
826            "multi" => req_builder.query(&param_value.into_iter().map(|p| ("providers".to_owned(), p.to_string())).collect::<Vec<(std::string::String, std::string::String)>>()),
827            _ => req_builder.query(&[("providers", &param_value.into_iter().map(|p| p.to_string()).collect::<Vec<String>>().join(",").to_string())]),
828        };
829    }
830    if let Some(ref param_value) = p_query_limit {
831        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
832    }
833    if let Some(ref param_value) = p_query_cursor {
834        req_builder = req_builder.query(&[("cursor", &param_value.to_string())]);
835    }
836    if let Some(ref user_agent) = configuration.user_agent {
837        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
838    }
839    if let Some(param_value) = p_header_x_workspace_id {
840        req_builder = req_builder.header("X-Workspace-ID", param_value.to_string());
841    }
842    if let Some(ref token) = configuration.bearer_access_token {
843        req_builder = req_builder.bearer_auth(token.to_owned());
844    };
845
846    let req = req_builder.build()?;
847    let resp = configuration.client.execute(req).await?;
848
849    let status = resp.status();
850    let content_type = resp
851        .headers()
852        .get("content-type")
853        .and_then(|v| v.to_str().ok())
854        .unwrap_or("application/octet-stream");
855    let content_type = super::ContentType::from(content_type);
856
857    if !status.is_client_error() && !status.is_server_error() {
858        let content = resp.text().await?;
859        match content_type {
860            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
861            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ListChatUsersResponse`"))),
862            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ListChatUsersResponse`")))),
863        }
864    } else {
865        let content = resp.text().await?;
866        let entity: Option<ListDmUsersError> = serde_json::from_str(&content).ok();
867        Err(Error::ResponseError(ResponseContent { status, content, entity }))
868    }
869}
870
871pub async fn mark_dm_read(configuration: &configuration::Configuration, dm_id: &str, dm_mark_read_request: models::DmMarkReadRequest) -> Result<models::SuccessFlag, Error<MarkDmReadError>> {
872    // add a prefix to parameters to efficiently prevent name collisions
873    let p_path_dm_id = dm_id;
874    let p_body_dm_mark_read_request = dm_mark_read_request;
875
876    let uri_str = format!("{}/v1/direct-messages/{dmId}/read", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
877    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
878
879    if let Some(ref user_agent) = configuration.user_agent {
880        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
881    }
882    if let Some(ref token) = configuration.bearer_access_token {
883        req_builder = req_builder.bearer_auth(token.to_owned());
884    };
885    req_builder = req_builder.json(&p_body_dm_mark_read_request);
886
887    let req = req_builder.build()?;
888    let resp = configuration.client.execute(req).await?;
889
890    let status = resp.status();
891    let content_type = resp
892        .headers()
893        .get("content-type")
894        .and_then(|v| v.to_str().ok())
895        .unwrap_or("application/octet-stream");
896    let content_type = super::ContentType::from(content_type);
897
898    if !status.is_client_error() && !status.is_server_error() {
899        let content = resp.text().await?;
900        match content_type {
901            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
902            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
903            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
904        }
905    } else {
906        let content = resp.text().await?;
907        let entity: Option<MarkDmReadError> = serde_json::from_str(&content).ok();
908        Err(Error::ResponseError(ResponseContent { status, content, entity }))
909    }
910}
911
912pub async fn mute_dm(configuration: &configuration::Configuration, dm_id: &str, dm_mute_request: models::DmMuteRequest) -> Result<models::DmMuteResponse, Error<MuteDmError>> {
913    // add a prefix to parameters to efficiently prevent name collisions
914    let p_path_dm_id = dm_id;
915    let p_body_dm_mute_request = dm_mute_request;
916
917    let uri_str = format!("{}/v1/direct-messages/{dmId}/mute", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
918    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
919
920    if let Some(ref user_agent) = configuration.user_agent {
921        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
922    }
923    if let Some(ref token) = configuration.bearer_access_token {
924        req_builder = req_builder.bearer_auth(token.to_owned());
925    };
926    req_builder = req_builder.json(&p_body_dm_mute_request);
927
928    let req = req_builder.build()?;
929    let resp = configuration.client.execute(req).await?;
930
931    let status = resp.status();
932    let content_type = resp
933        .headers()
934        .get("content-type")
935        .and_then(|v| v.to_str().ok())
936        .unwrap_or("application/octet-stream");
937    let content_type = super::ContentType::from(content_type);
938
939    if !status.is_client_error() && !status.is_server_error() {
940        let content = resp.text().await?;
941        match content_type {
942            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
943            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmMuteResponse`"))),
944            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmMuteResponse`")))),
945        }
946    } else {
947        let content = resp.text().await?;
948        let entity: Option<MuteDmError> = serde_json::from_str(&content).ok();
949        Err(Error::ResponseError(ResponseContent { status, content, entity }))
950    }
951}
952
953pub async fn pin_dm_conversation(configuration: &configuration::Configuration, dm_id: &str, account_id: Option<&str>) -> Result<models::SuccessFlag, Error<PinDmConversationError>> {
954    // add a prefix to parameters to efficiently prevent name collisions
955    let p_path_dm_id = dm_id;
956    let p_query_account_id = account_id;
957
958    let uri_str = format!("{}/v1/direct-messages/{dmId}/pin", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
959    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
960
961    if let Some(ref param_value) = p_query_account_id {
962        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
963    }
964    if let Some(ref user_agent) = configuration.user_agent {
965        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
966    }
967    if let Some(ref token) = configuration.bearer_access_token {
968        req_builder = req_builder.bearer_auth(token.to_owned());
969    };
970
971    let req = req_builder.build()?;
972    let resp = configuration.client.execute(req).await?;
973
974    let status = resp.status();
975    let content_type = resp
976        .headers()
977        .get("content-type")
978        .and_then(|v| v.to_str().ok())
979        .unwrap_or("application/octet-stream");
980    let content_type = super::ContentType::from(content_type);
981
982    if !status.is_client_error() && !status.is_server_error() {
983        let content = resp.text().await?;
984        match content_type {
985            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
986            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
987            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
988        }
989    } else {
990        let content = resp.text().await?;
991        let entity: Option<PinDmConversationError> = serde_json::from_str(&content).ok();
992        Err(Error::ResponseError(ResponseContent { status, content, entity }))
993    }
994}
995
996pub async fn pin_dm_message(configuration: &configuration::Configuration, message_id: &str, channel_membership_request: Option<models::ChannelMembershipRequest>) -> Result<models::SuccessFlag, Error<PinDmMessageError>> {
997    // add a prefix to parameters to efficiently prevent name collisions
998    let p_path_message_id = message_id;
999    let p_body_channel_membership_request = channel_membership_request;
1000
1001    let uri_str = format!("{}/v1/direct-messages/messages/{messageId}/pin", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
1002    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1003
1004    if let Some(ref user_agent) = configuration.user_agent {
1005        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1006    }
1007    if let Some(ref token) = configuration.bearer_access_token {
1008        req_builder = req_builder.bearer_auth(token.to_owned());
1009    };
1010    req_builder = req_builder.json(&p_body_channel_membership_request);
1011
1012    let req = req_builder.build()?;
1013    let resp = configuration.client.execute(req).await?;
1014
1015    let status = resp.status();
1016    let content_type = resp
1017        .headers()
1018        .get("content-type")
1019        .and_then(|v| v.to_str().ok())
1020        .unwrap_or("application/octet-stream");
1021    let content_type = super::ContentType::from(content_type);
1022
1023    if !status.is_client_error() && !status.is_server_error() {
1024        let content = resp.text().await?;
1025        match content_type {
1026            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1027            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
1028            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
1029        }
1030    } else {
1031        let content = resp.text().await?;
1032        let entity: Option<PinDmMessageError> = serde_json::from_str(&content).ok();
1033        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1034    }
1035}
1036
1037pub async fn post_dm_thread_reply(configuration: &configuration::Configuration, dm_id: &str, message_id: &str, dm_thread_reply_request: models::DmThreadReplyRequest, account_id: Option<&str>) -> Result<models::DmMessageEnvelope, Error<PostDmThreadReplyError>> {
1038    // add a prefix to parameters to efficiently prevent name collisions
1039    let p_path_dm_id = dm_id;
1040    let p_path_message_id = message_id;
1041    let p_body_dm_thread_reply_request = dm_thread_reply_request;
1042    let p_query_account_id = account_id;
1043
1044    let uri_str = format!("{}/v1/direct-messages/{dmId}/messages/{messageId}/replies", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id), messageId=crate::apis::urlencode(p_path_message_id));
1045    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1046
1047    if let Some(ref param_value) = p_query_account_id {
1048        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
1049    }
1050    if let Some(ref user_agent) = configuration.user_agent {
1051        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1052    }
1053    if let Some(ref token) = configuration.bearer_access_token {
1054        req_builder = req_builder.bearer_auth(token.to_owned());
1055    };
1056    req_builder = req_builder.json(&p_body_dm_thread_reply_request);
1057
1058    let req = req_builder.build()?;
1059    let resp = configuration.client.execute(req).await?;
1060
1061    let status = resp.status();
1062    let content_type = resp
1063        .headers()
1064        .get("content-type")
1065        .and_then(|v| v.to_str().ok())
1066        .unwrap_or("application/octet-stream");
1067    let content_type = super::ContentType::from(content_type);
1068
1069    if !status.is_client_error() && !status.is_server_error() {
1070        let content = resp.text().await?;
1071        match content_type {
1072            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1073            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmMessageEnvelope`"))),
1074            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmMessageEnvelope`")))),
1075        }
1076    } else {
1077        let content = resp.text().await?;
1078        let entity: Option<PostDmThreadReplyError> = serde_json::from_str(&content).ok();
1079        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1080    }
1081}
1082
1083pub async fn remove_dm_reaction(configuration: &configuration::Configuration, message_id: &str, emoji: &str, account_id: Option<&str>) -> Result<models::DmReactionResponse, Error<RemoveDmReactionError>> {
1084    // add a prefix to parameters to efficiently prevent name collisions
1085    let p_path_message_id = message_id;
1086    let p_path_emoji = emoji;
1087    let p_query_account_id = account_id;
1088
1089    let uri_str = format!("{}/v1/direct-messages/messages/{messageId}/reactions/{emoji}", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id), emoji=crate::apis::urlencode(p_path_emoji));
1090    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1091
1092    if let Some(ref param_value) = p_query_account_id {
1093        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
1094    }
1095    if let Some(ref user_agent) = configuration.user_agent {
1096        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1097    }
1098    if let Some(ref token) = configuration.bearer_access_token {
1099        req_builder = req_builder.bearer_auth(token.to_owned());
1100    };
1101
1102    let req = req_builder.build()?;
1103    let resp = configuration.client.execute(req).await?;
1104
1105    let status = resp.status();
1106    let content_type = resp
1107        .headers()
1108        .get("content-type")
1109        .and_then(|v| v.to_str().ok())
1110        .unwrap_or("application/octet-stream");
1111    let content_type = super::ContentType::from(content_type);
1112
1113    if !status.is_client_error() && !status.is_server_error() {
1114        let content = resp.text().await?;
1115        match content_type {
1116            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1117            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmReactionResponse`"))),
1118            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmReactionResponse`")))),
1119        }
1120    } else {
1121        let content = resp.text().await?;
1122        let entity: Option<RemoveDmReactionError> = serde_json::from_str(&content).ok();
1123        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1124    }
1125}
1126
1127pub async fn search_direct_messages(configuration: &configuration::Configuration, q: &str, limit: Option<i32>, dm_id: Option<&str>, user: Option<&str>, account_id: Option<&str>) -> Result<models::DmSearchResults, Error<SearchDirectMessagesError>> {
1128    // add a prefix to parameters to efficiently prevent name collisions
1129    let p_query_q = q;
1130    let p_query_limit = limit;
1131    let p_query_dm_id = dm_id;
1132    let p_query_user = user;
1133    let p_query_account_id = account_id;
1134
1135    let uri_str = format!("{}/v1/direct-messages/search", configuration.base_path);
1136    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1137
1138    req_builder = req_builder.query(&[("q", &p_query_q.to_string())]);
1139    if let Some(ref param_value) = p_query_limit {
1140        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
1141    }
1142    if let Some(ref param_value) = p_query_dm_id {
1143        req_builder = req_builder.query(&[("dmId", &param_value.to_string())]);
1144    }
1145    if let Some(ref param_value) = p_query_user {
1146        req_builder = req_builder.query(&[("user", &param_value.to_string())]);
1147    }
1148    if let Some(ref param_value) = p_query_account_id {
1149        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
1150    }
1151    if let Some(ref user_agent) = configuration.user_agent {
1152        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1153    }
1154    if let Some(ref token) = configuration.bearer_access_token {
1155        req_builder = req_builder.bearer_auth(token.to_owned());
1156    };
1157
1158    let req = req_builder.build()?;
1159    let resp = configuration.client.execute(req).await?;
1160
1161    let status = resp.status();
1162    let content_type = resp
1163        .headers()
1164        .get("content-type")
1165        .and_then(|v| v.to_str().ok())
1166        .unwrap_or("application/octet-stream");
1167    let content_type = super::ContentType::from(content_type);
1168
1169    if !status.is_client_error() && !status.is_server_error() {
1170        let content = resp.text().await?;
1171        match content_type {
1172            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1173            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DmSearchResults`"))),
1174            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DmSearchResults`")))),
1175        }
1176    } else {
1177        let content = resp.text().await?;
1178        let entity: Option<SearchDirectMessagesError> = serde_json::from_str(&content).ok();
1179        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1180    }
1181}
1182
1183pub async fn send_direct_message(configuration: &configuration::Configuration, send_chat_message_request: models::SendChatMessageRequest) -> Result<models::SendChatMessageResponse, Error<SendDirectMessageError>> {
1184    // add a prefix to parameters to efficiently prevent name collisions
1185    let p_body_send_chat_message_request = send_chat_message_request;
1186
1187    let uri_str = format!("{}/v1/direct-messages/messages", configuration.base_path);
1188    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1189
1190    if let Some(ref user_agent) = configuration.user_agent {
1191        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1192    }
1193    if let Some(ref token) = configuration.bearer_access_token {
1194        req_builder = req_builder.bearer_auth(token.to_owned());
1195    };
1196    req_builder = req_builder.json(&p_body_send_chat_message_request);
1197
1198    let req = req_builder.build()?;
1199    let resp = configuration.client.execute(req).await?;
1200
1201    let status = resp.status();
1202    let content_type = resp
1203        .headers()
1204        .get("content-type")
1205        .and_then(|v| v.to_str().ok())
1206        .unwrap_or("application/octet-stream");
1207    let content_type = super::ContentType::from(content_type);
1208
1209    if !status.is_client_error() && !status.is_server_error() {
1210        let content = resp.text().await?;
1211        match content_type {
1212            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1213            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SendChatMessageResponse`"))),
1214            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SendChatMessageResponse`")))),
1215        }
1216    } else {
1217        let content = resp.text().await?;
1218        let entity: Option<SendDirectMessageError> = serde_json::from_str(&content).ok();
1219        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1220    }
1221}
1222
1223pub async fn set_dm_draft(configuration: &configuration::Configuration, dm_id: &str, dm_set_draft_request: models::DmSetDraftRequest) -> Result<models::SuccessFlag, Error<SetDmDraftError>> {
1224    // add a prefix to parameters to efficiently prevent name collisions
1225    let p_path_dm_id = dm_id;
1226    let p_body_dm_set_draft_request = dm_set_draft_request;
1227
1228    let uri_str = format!("{}/v1/direct-messages/{dmId}/draft", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
1229    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
1230
1231    if let Some(ref user_agent) = configuration.user_agent {
1232        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1233    }
1234    if let Some(ref token) = configuration.bearer_access_token {
1235        req_builder = req_builder.bearer_auth(token.to_owned());
1236    };
1237    req_builder = req_builder.json(&p_body_dm_set_draft_request);
1238
1239    let req = req_builder.build()?;
1240    let resp = configuration.client.execute(req).await?;
1241
1242    let status = resp.status();
1243    let content_type = resp
1244        .headers()
1245        .get("content-type")
1246        .and_then(|v| v.to_str().ok())
1247        .unwrap_or("application/octet-stream");
1248    let content_type = super::ContentType::from(content_type);
1249
1250    if !status.is_client_error() && !status.is_server_error() {
1251        let content = resp.text().await?;
1252        match content_type {
1253            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1254            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
1255            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
1256        }
1257    } else {
1258        let content = resp.text().await?;
1259        let entity: Option<SetDmDraftError> = serde_json::from_str(&content).ok();
1260        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1261    }
1262}
1263
1264pub async fn unpin_dm_conversation(configuration: &configuration::Configuration, dm_id: &str, account_id: Option<&str>) -> Result<models::SuccessFlag, Error<UnpinDmConversationError>> {
1265    // add a prefix to parameters to efficiently prevent name collisions
1266    let p_path_dm_id = dm_id;
1267    let p_query_account_id = account_id;
1268
1269    let uri_str = format!("{}/v1/direct-messages/{dmId}/pin", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
1270    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1271
1272    if let Some(ref param_value) = p_query_account_id {
1273        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
1274    }
1275    if let Some(ref user_agent) = configuration.user_agent {
1276        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1277    }
1278    if let Some(ref token) = configuration.bearer_access_token {
1279        req_builder = req_builder.bearer_auth(token.to_owned());
1280    };
1281
1282    let req = req_builder.build()?;
1283    let resp = configuration.client.execute(req).await?;
1284
1285    let status = resp.status();
1286    let content_type = resp
1287        .headers()
1288        .get("content-type")
1289        .and_then(|v| v.to_str().ok())
1290        .unwrap_or("application/octet-stream");
1291    let content_type = super::ContentType::from(content_type);
1292
1293    if !status.is_client_error() && !status.is_server_error() {
1294        let content = resp.text().await?;
1295        match content_type {
1296            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1297            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
1298            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
1299        }
1300    } else {
1301        let content = resp.text().await?;
1302        let entity: Option<UnpinDmConversationError> = serde_json::from_str(&content).ok();
1303        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1304    }
1305}
1306
1307pub async fn unpin_dm_message(configuration: &configuration::Configuration, message_id: &str, account_id: Option<&str>) -> Result<models::SuccessFlag, Error<UnpinDmMessageError>> {
1308    // add a prefix to parameters to efficiently prevent name collisions
1309    let p_path_message_id = message_id;
1310    let p_query_account_id = account_id;
1311
1312    let uri_str = format!("{}/v1/direct-messages/messages/{messageId}/pin", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
1313    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1314
1315    if let Some(ref param_value) = p_query_account_id {
1316        req_builder = req_builder.query(&[("accountId", &param_value.to_string())]);
1317    }
1318    if let Some(ref user_agent) = configuration.user_agent {
1319        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1320    }
1321    if let Some(ref token) = configuration.bearer_access_token {
1322        req_builder = req_builder.bearer_auth(token.to_owned());
1323    };
1324
1325    let req = req_builder.build()?;
1326    let resp = configuration.client.execute(req).await?;
1327
1328    let status = resp.status();
1329    let content_type = resp
1330        .headers()
1331        .get("content-type")
1332        .and_then(|v| v.to_str().ok())
1333        .unwrap_or("application/octet-stream");
1334    let content_type = super::ContentType::from(content_type);
1335
1336    if !status.is_client_error() && !status.is_server_error() {
1337        let content = resp.text().await?;
1338        match content_type {
1339            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1340            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessFlag`"))),
1341            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessFlag`")))),
1342        }
1343    } else {
1344        let content = resp.text().await?;
1345        let entity: Option<UnpinDmMessageError> = serde_json::from_str(&content).ok();
1346        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1347    }
1348}
1349
1350pub async fn workspace_execute_dm_action(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceExecuteDmActionError>> {
1351    // add a prefix to parameters to efficiently prevent name collisions
1352    let p_path_org = org;
1353    let p_path_workspace = workspace;
1354    let p_body_request_body = request_body;
1355
1356    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/execute", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1357    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1358
1359    if let Some(ref user_agent) = configuration.user_agent {
1360        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1361    }
1362    if let Some(ref token) = configuration.bearer_access_token {
1363        req_builder = req_builder.bearer_auth(token.to_owned());
1364    };
1365    req_builder = req_builder.json(&p_body_request_body);
1366
1367    let req = req_builder.build()?;
1368    let resp = configuration.client.execute(req).await?;
1369
1370    let status = resp.status();
1371    let content_type = resp
1372        .headers()
1373        .get("content-type")
1374        .and_then(|v| v.to_str().ok())
1375        .unwrap_or("application/octet-stream");
1376    let content_type = super::ContentType::from(content_type);
1377
1378    if !status.is_client_error() && !status.is_server_error() {
1379        let content = resp.text().await?;
1380        match content_type {
1381            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1382            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1383            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1384        }
1385    } else {
1386        let content = resp.text().await?;
1387        let entity: Option<WorkspaceExecuteDmActionError> = serde_json::from_str(&content).ok();
1388        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1389    }
1390}
1391
1392pub async fn workspace_get_dm_user(configuration: &configuration::Configuration, org: &str, workspace: &str, id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceGetDmUserError>> {
1393    // add a prefix to parameters to efficiently prevent name collisions
1394    let p_path_org = org;
1395    let p_path_workspace = workspace;
1396    let p_path_id = id;
1397
1398    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/users/{id}", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace), id=crate::apis::urlencode(p_path_id));
1399    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1400
1401    if let Some(ref user_agent) = configuration.user_agent {
1402        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1403    }
1404    if let Some(ref token) = configuration.bearer_access_token {
1405        req_builder = req_builder.bearer_auth(token.to_owned());
1406    };
1407
1408    let req = req_builder.build()?;
1409    let resp = configuration.client.execute(req).await?;
1410
1411    let status = resp.status();
1412    let content_type = resp
1413        .headers()
1414        .get("content-type")
1415        .and_then(|v| v.to_str().ok())
1416        .unwrap_or("application/octet-stream");
1417    let content_type = super::ContentType::from(content_type);
1418
1419    if !status.is_client_error() && !status.is_server_error() {
1420        let content = resp.text().await?;
1421        match content_type {
1422            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1423            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1424            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1425        }
1426    } else {
1427        let content = resp.text().await?;
1428        let entity: Option<WorkspaceGetDmUserError> = serde_json::from_str(&content).ok();
1429        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1430    }
1431}
1432
1433pub async fn workspace_list_direct_messages(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListDirectMessagesError>> {
1434    // add a prefix to parameters to efficiently prevent name collisions
1435    let p_path_org = org;
1436    let p_path_workspace = workspace;
1437
1438    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1439    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1440
1441    if let Some(ref user_agent) = configuration.user_agent {
1442        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1443    }
1444    if let Some(ref token) = configuration.bearer_access_token {
1445        req_builder = req_builder.bearer_auth(token.to_owned());
1446    };
1447
1448    let req = req_builder.build()?;
1449    let resp = configuration.client.execute(req).await?;
1450
1451    let status = resp.status();
1452    let content_type = resp
1453        .headers()
1454        .get("content-type")
1455        .and_then(|v| v.to_str().ok())
1456        .unwrap_or("application/octet-stream");
1457    let content_type = super::ContentType::from(content_type);
1458
1459    if !status.is_client_error() && !status.is_server_error() {
1460        let content = resp.text().await?;
1461        match content_type {
1462            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1463            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1464            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1465        }
1466    } else {
1467        let content = resp.text().await?;
1468        let entity: Option<WorkspaceListDirectMessagesError> = serde_json::from_str(&content).ok();
1469        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1470    }
1471}
1472
1473pub async fn workspace_list_dm_actions(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListDmActionsError>> {
1474    // add a prefix to parameters to efficiently prevent name collisions
1475    let p_path_org = org;
1476    let p_path_workspace = workspace;
1477
1478    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/actions", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1479    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1480
1481    if let Some(ref user_agent) = configuration.user_agent {
1482        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1483    }
1484    if let Some(ref token) = configuration.bearer_access_token {
1485        req_builder = req_builder.bearer_auth(token.to_owned());
1486    };
1487
1488    let req = req_builder.build()?;
1489    let resp = configuration.client.execute(req).await?;
1490
1491    let status = resp.status();
1492    let content_type = resp
1493        .headers()
1494        .get("content-type")
1495        .and_then(|v| v.to_str().ok())
1496        .unwrap_or("application/octet-stream");
1497    let content_type = super::ContentType::from(content_type);
1498
1499    if !status.is_client_error() && !status.is_server_error() {
1500        let content = resp.text().await?;
1501        match content_type {
1502            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1503            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1504            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1505        }
1506    } else {
1507        let content = resp.text().await?;
1508        let entity: Option<WorkspaceListDmActionsError> = serde_json::from_str(&content).ok();
1509        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1510    }
1511}
1512
1513pub async fn workspace_list_dm_conversations(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListDmConversationsError>> {
1514    // add a prefix to parameters to efficiently prevent name collisions
1515    let p_path_org = org;
1516    let p_path_workspace = workspace;
1517
1518    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/conversations", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1519    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1520
1521    if let Some(ref user_agent) = configuration.user_agent {
1522        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1523    }
1524    if let Some(ref token) = configuration.bearer_access_token {
1525        req_builder = req_builder.bearer_auth(token.to_owned());
1526    };
1527
1528    let req = req_builder.build()?;
1529    let resp = configuration.client.execute(req).await?;
1530
1531    let status = resp.status();
1532    let content_type = resp
1533        .headers()
1534        .get("content-type")
1535        .and_then(|v| v.to_str().ok())
1536        .unwrap_or("application/octet-stream");
1537    let content_type = super::ContentType::from(content_type);
1538
1539    if !status.is_client_error() && !status.is_server_error() {
1540        let content = resp.text().await?;
1541        match content_type {
1542            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1543            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1544            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1545        }
1546    } else {
1547        let content = resp.text().await?;
1548        let entity: Option<WorkspaceListDmConversationsError> = serde_json::from_str(&content).ok();
1549        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1550    }
1551}
1552
1553pub async fn workspace_list_dm_messages(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListDmMessagesError>> {
1554    // add a prefix to parameters to efficiently prevent name collisions
1555    let p_path_org = org;
1556    let p_path_workspace = workspace;
1557
1558    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/messages", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1559    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1560
1561    if let Some(ref user_agent) = configuration.user_agent {
1562        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1563    }
1564    if let Some(ref token) = configuration.bearer_access_token {
1565        req_builder = req_builder.bearer_auth(token.to_owned());
1566    };
1567
1568    let req = req_builder.build()?;
1569    let resp = configuration.client.execute(req).await?;
1570
1571    let status = resp.status();
1572    let content_type = resp
1573        .headers()
1574        .get("content-type")
1575        .and_then(|v| v.to_str().ok())
1576        .unwrap_or("application/octet-stream");
1577    let content_type = super::ContentType::from(content_type);
1578
1579    if !status.is_client_error() && !status.is_server_error() {
1580        let content = resp.text().await?;
1581        match content_type {
1582            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1583            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1584            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1585        }
1586    } else {
1587        let content = resp.text().await?;
1588        let entity: Option<WorkspaceListDmMessagesError> = serde_json::from_str(&content).ok();
1589        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1590    }
1591}
1592
1593pub async fn workspace_list_dm_users(configuration: &configuration::Configuration, org: &str, workspace: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceListDmUsersError>> {
1594    // add a prefix to parameters to efficiently prevent name collisions
1595    let p_path_org = org;
1596    let p_path_workspace = workspace;
1597
1598    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/users", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1599    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1600
1601    if let Some(ref user_agent) = configuration.user_agent {
1602        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1603    }
1604    if let Some(ref token) = configuration.bearer_access_token {
1605        req_builder = req_builder.bearer_auth(token.to_owned());
1606    };
1607
1608    let req = req_builder.build()?;
1609    let resp = configuration.client.execute(req).await?;
1610
1611    let status = resp.status();
1612    let content_type = resp
1613        .headers()
1614        .get("content-type")
1615        .and_then(|v| v.to_str().ok())
1616        .unwrap_or("application/octet-stream");
1617    let content_type = super::ContentType::from(content_type);
1618
1619    if !status.is_client_error() && !status.is_server_error() {
1620        let content = resp.text().await?;
1621        match content_type {
1622            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1623            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1624            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1625        }
1626    } else {
1627        let content = resp.text().await?;
1628        let entity: Option<WorkspaceListDmUsersError> = serde_json::from_str(&content).ok();
1629        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1630    }
1631}
1632
1633pub async fn workspace_send_direct_message(configuration: &configuration::Configuration, org: &str, workspace: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<WorkspaceSendDirectMessageError>> {
1634    // add a prefix to parameters to efficiently prevent name collisions
1635    let p_path_org = org;
1636    let p_path_workspace = workspace;
1637    let p_body_request_body = request_body;
1638
1639    let uri_str = format!("{}/v1/organizations/{org}/workspaces/{workspace}/direct-messages/messages", configuration.base_path, org=crate::apis::urlencode(p_path_org), workspace=crate::apis::urlencode(p_path_workspace));
1640    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1641
1642    if let Some(ref user_agent) = configuration.user_agent {
1643        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1644    }
1645    if let Some(ref token) = configuration.bearer_access_token {
1646        req_builder = req_builder.bearer_auth(token.to_owned());
1647    };
1648    req_builder = req_builder.json(&p_body_request_body);
1649
1650    let req = req_builder.build()?;
1651    let resp = configuration.client.execute(req).await?;
1652
1653    let status = resp.status();
1654    let content_type = resp
1655        .headers()
1656        .get("content-type")
1657        .and_then(|v| v.to_str().ok())
1658        .unwrap_or("application/octet-stream");
1659    let content_type = super::ContentType::from(content_type);
1660
1661    if !status.is_client_error() && !status.is_server_error() {
1662        let content = resp.text().await?;
1663        match content_type {
1664            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1665            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`"))),
1666            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `std::collections::HashMap&lt;String, serde_json::Value&gt;`")))),
1667        }
1668    } else {
1669        let content = resp.text().await?;
1670        let entity: Option<WorkspaceSendDirectMessageError> = serde_json::from_str(&content).ok();
1671        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1672    }
1673}
1674