Skip to main content

spatio_sdk/apis/
native_dm_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_native_dm_reaction`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddNativeDmReactionError {
22    Status401(models::ApiError),
23    UnknownValue(serde_json::Value),
24}
25
26/// struct for typed errors of method [`attach_to_native_dm_message`]
27#[derive(Debug, Clone, Serialize, Deserialize)]
28#[serde(untagged)]
29pub enum AttachToNativeDmMessageError {
30    Status401(models::ApiError),
31    UnknownValue(serde_json::Value),
32}
33
34/// struct for typed errors of method [`delete_native_dm_message`]
35#[derive(Debug, Clone, Serialize, Deserialize)]
36#[serde(untagged)]
37pub enum DeleteNativeDmMessageError {
38    Status401(models::ApiError),
39    UnknownValue(serde_json::Value),
40}
41
42/// struct for typed errors of method [`forward_native_dm_message`]
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum ForwardNativeDmMessageError {
46    Status401(models::ApiError),
47    UnknownValue(serde_json::Value),
48}
49
50/// struct for typed errors of method [`list_native_dm_channels`]
51#[derive(Debug, Clone, Serialize, Deserialize)]
52#[serde(untagged)]
53pub enum ListNativeDmChannelsError {
54    Status401(models::ApiError),
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`list_native_dm_conversations`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum ListNativeDmConversationsError {
62    Status401(models::ApiError),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`list_native_dm_messages`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum ListNativeDmMessagesError {
70    Status401(models::ApiError),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`list_native_dm_pinned_messages`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum ListNativeDmPinnedMessagesError {
78    Status401(models::ApiError),
79    UnknownValue(serde_json::Value),
80}
81
82/// struct for typed errors of method [`list_native_dm_thread_replies`]
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum ListNativeDmThreadRepliesError {
86    Status401(models::ApiError),
87    UnknownValue(serde_json::Value),
88}
89
90/// struct for typed errors of method [`mark_native_dm_read`]
91#[derive(Debug, Clone, Serialize, Deserialize)]
92#[serde(untagged)]
93pub enum MarkNativeDmReadError {
94    Status401(models::ApiError),
95    UnknownValue(serde_json::Value),
96}
97
98/// struct for typed errors of method [`mute_native_dm`]
99#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum MuteNativeDmError {
102    Status401(models::ApiError),
103    UnknownValue(serde_json::Value),
104}
105
106/// struct for typed errors of method [`pin_native_dm_conversation`]
107#[derive(Debug, Clone, Serialize, Deserialize)]
108#[serde(untagged)]
109pub enum PinNativeDmConversationError {
110    Status401(models::ApiError),
111    UnknownValue(serde_json::Value),
112}
113
114/// struct for typed errors of method [`pin_native_dm_message`]
115#[derive(Debug, Clone, Serialize, Deserialize)]
116#[serde(untagged)]
117pub enum PinNativeDmMessageError {
118    Status401(models::ApiError),
119    UnknownValue(serde_json::Value),
120}
121
122/// struct for typed errors of method [`post_native_dm_message`]
123#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum PostNativeDmMessageError {
126    Status401(models::ApiError),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`post_native_dm_thread_reply`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum PostNativeDmThreadReplyError {
134    Status401(models::ApiError),
135    UnknownValue(serde_json::Value),
136}
137
138/// struct for typed errors of method [`remove_native_dm_reaction`]
139#[derive(Debug, Clone, Serialize, Deserialize)]
140#[serde(untagged)]
141pub enum RemoveNativeDmReactionError {
142    Status401(models::ApiError),
143    UnknownValue(serde_json::Value),
144}
145
146/// struct for typed errors of method [`search_native_dm_messages`]
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[serde(untagged)]
149pub enum SearchNativeDmMessagesError {
150    Status401(models::ApiError),
151    UnknownValue(serde_json::Value),
152}
153
154/// struct for typed errors of method [`set_native_dm_draft`]
155#[derive(Debug, Clone, Serialize, Deserialize)]
156#[serde(untagged)]
157pub enum SetNativeDmDraftError {
158    Status401(models::ApiError),
159    UnknownValue(serde_json::Value),
160}
161
162/// struct for typed errors of method [`unpin_native_dm_conversation`]
163#[derive(Debug, Clone, Serialize, Deserialize)]
164#[serde(untagged)]
165pub enum UnpinNativeDmConversationError {
166    Status401(models::ApiError),
167    UnknownValue(serde_json::Value),
168}
169
170/// struct for typed errors of method [`unpin_native_dm_message`]
171#[derive(Debug, Clone, Serialize, Deserialize)]
172#[serde(untagged)]
173pub enum UnpinNativeDmMessageError {
174    Status401(models::ApiError),
175    UnknownValue(serde_json::Value),
176}
177
178/// struct for typed errors of method [`update_native_dm_message`]
179#[derive(Debug, Clone, Serialize, Deserialize)]
180#[serde(untagged)]
181pub enum UpdateNativeDmMessageError {
182    Status401(models::ApiError),
183    UnknownValue(serde_json::Value),
184}
185
186
187pub async fn add_native_dm_reaction(configuration: &configuration::Configuration, message_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<AddNativeDmReactionError>> {
188    // add a prefix to parameters to efficiently prevent name collisions
189    let p_path_message_id = message_id;
190    let p_body_request_body = request_body;
191
192    let uri_str = format!("{}/v1/native/dm/messages/{messageId}/reactions", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
193    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
194
195    if let Some(ref user_agent) = configuration.user_agent {
196        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
197    }
198    if let Some(ref token) = configuration.bearer_access_token {
199        req_builder = req_builder.bearer_auth(token.to_owned());
200    };
201    req_builder = req_builder.json(&p_body_request_body);
202
203    let req = req_builder.build()?;
204    let resp = configuration.client.execute(req).await?;
205
206    let status = resp.status();
207    let content_type = resp
208        .headers()
209        .get("content-type")
210        .and_then(|v| v.to_str().ok())
211        .unwrap_or("application/octet-stream");
212    let content_type = super::ContentType::from(content_type);
213
214    if !status.is_client_error() && !status.is_server_error() {
215        let content = resp.text().await?;
216        match content_type {
217            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
218            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;`"))),
219            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;`")))),
220        }
221    } else {
222        let content = resp.text().await?;
223        let entity: Option<AddNativeDmReactionError> = serde_json::from_str(&content).ok();
224        Err(Error::ResponseError(ResponseContent { status, content, entity }))
225    }
226}
227
228pub async fn attach_to_native_dm_message(configuration: &configuration::Configuration, message_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<AttachToNativeDmMessageError>> {
229    // add a prefix to parameters to efficiently prevent name collisions
230    let p_path_message_id = message_id;
231    let p_body_request_body = request_body;
232
233    let uri_str = format!("{}/v1/native/dm/messages/{messageId}/attachments", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
234    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
235
236    if let Some(ref user_agent) = configuration.user_agent {
237        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
238    }
239    if let Some(ref token) = configuration.bearer_access_token {
240        req_builder = req_builder.bearer_auth(token.to_owned());
241    };
242    req_builder = req_builder.json(&p_body_request_body);
243
244    let req = req_builder.build()?;
245    let resp = configuration.client.execute(req).await?;
246
247    let status = resp.status();
248    let content_type = resp
249        .headers()
250        .get("content-type")
251        .and_then(|v| v.to_str().ok())
252        .unwrap_or("application/octet-stream");
253    let content_type = super::ContentType::from(content_type);
254
255    if !status.is_client_error() && !status.is_server_error() {
256        let content = resp.text().await?;
257        match content_type {
258            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
259            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;`"))),
260            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;`")))),
261        }
262    } else {
263        let content = resp.text().await?;
264        let entity: Option<AttachToNativeDmMessageError> = serde_json::from_str(&content).ok();
265        Err(Error::ResponseError(ResponseContent { status, content, entity }))
266    }
267}
268
269pub async fn delete_native_dm_message(configuration: &configuration::Configuration, dm_id: &str, message_id: &str) -> Result<(), Error<DeleteNativeDmMessageError>> {
270    // add a prefix to parameters to efficiently prevent name collisions
271    let p_path_dm_id = dm_id;
272    let p_path_message_id = message_id;
273
274    let uri_str = format!("{}/v1/native/dm/{dmId}/messages/{messageId}", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id), messageId=crate::apis::urlencode(p_path_message_id));
275    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
276
277    if let Some(ref user_agent) = configuration.user_agent {
278        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
279    }
280    if let Some(ref token) = configuration.bearer_access_token {
281        req_builder = req_builder.bearer_auth(token.to_owned());
282    };
283
284    let req = req_builder.build()?;
285    let resp = configuration.client.execute(req).await?;
286
287    let status = resp.status();
288
289    if !status.is_client_error() && !status.is_server_error() {
290        Ok(())
291    } else {
292        let content = resp.text().await?;
293        let entity: Option<DeleteNativeDmMessageError> = serde_json::from_str(&content).ok();
294        Err(Error::ResponseError(ResponseContent { status, content, entity }))
295    }
296}
297
298pub async fn forward_native_dm_message(configuration: &configuration::Configuration, message_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ForwardNativeDmMessageError>> {
299    // add a prefix to parameters to efficiently prevent name collisions
300    let p_path_message_id = message_id;
301    let p_body_request_body = request_body;
302
303    let uri_str = format!("{}/v1/native/dm/messages/{messageId}/forward", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
304    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
305
306    if let Some(ref user_agent) = configuration.user_agent {
307        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
308    }
309    if let Some(ref token) = configuration.bearer_access_token {
310        req_builder = req_builder.bearer_auth(token.to_owned());
311    };
312    req_builder = req_builder.json(&p_body_request_body);
313
314    let req = req_builder.build()?;
315    let resp = configuration.client.execute(req).await?;
316
317    let status = resp.status();
318    let content_type = resp
319        .headers()
320        .get("content-type")
321        .and_then(|v| v.to_str().ok())
322        .unwrap_or("application/octet-stream");
323    let content_type = super::ContentType::from(content_type);
324
325    if !status.is_client_error() && !status.is_server_error() {
326        let content = resp.text().await?;
327        match content_type {
328            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
329            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;`"))),
330            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;`")))),
331        }
332    } else {
333        let content = resp.text().await?;
334        let entity: Option<ForwardNativeDmMessageError> = serde_json::from_str(&content).ok();
335        Err(Error::ResponseError(ResponseContent { status, content, entity }))
336    }
337}
338
339pub async fn list_native_dm_channels(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListNativeDmChannelsError>> {
340
341    let uri_str = format!("{}/v1/native/dm", configuration.base_path);
342    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
343
344    if let Some(ref user_agent) = configuration.user_agent {
345        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
346    }
347    if let Some(ref token) = configuration.bearer_access_token {
348        req_builder = req_builder.bearer_auth(token.to_owned());
349    };
350
351    let req = req_builder.build()?;
352    let resp = configuration.client.execute(req).await?;
353
354    let status = resp.status();
355    let content_type = resp
356        .headers()
357        .get("content-type")
358        .and_then(|v| v.to_str().ok())
359        .unwrap_or("application/octet-stream");
360    let content_type = super::ContentType::from(content_type);
361
362    if !status.is_client_error() && !status.is_server_error() {
363        let content = resp.text().await?;
364        match content_type {
365            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
366            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;`"))),
367            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;`")))),
368        }
369    } else {
370        let content = resp.text().await?;
371        let entity: Option<ListNativeDmChannelsError> = serde_json::from_str(&content).ok();
372        Err(Error::ResponseError(ResponseContent { status, content, entity }))
373    }
374}
375
376pub async fn list_native_dm_conversations(configuration: &configuration::Configuration, ) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListNativeDmConversationsError>> {
377
378    let uri_str = format!("{}/v1/native/dm/conversations", configuration.base_path);
379    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
380
381    if let Some(ref user_agent) = configuration.user_agent {
382        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
383    }
384    if let Some(ref token) = configuration.bearer_access_token {
385        req_builder = req_builder.bearer_auth(token.to_owned());
386    };
387
388    let req = req_builder.build()?;
389    let resp = configuration.client.execute(req).await?;
390
391    let status = resp.status();
392    let content_type = resp
393        .headers()
394        .get("content-type")
395        .and_then(|v| v.to_str().ok())
396        .unwrap_or("application/octet-stream");
397    let content_type = super::ContentType::from(content_type);
398
399    if !status.is_client_error() && !status.is_server_error() {
400        let content = resp.text().await?;
401        match content_type {
402            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
403            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;`"))),
404            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;`")))),
405        }
406    } else {
407        let content = resp.text().await?;
408        let entity: Option<ListNativeDmConversationsError> = serde_json::from_str(&content).ok();
409        Err(Error::ResponseError(ResponseContent { status, content, entity }))
410    }
411}
412
413pub async fn list_native_dm_messages(configuration: &configuration::Configuration, dm_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListNativeDmMessagesError>> {
414    // add a prefix to parameters to efficiently prevent name collisions
415    let p_path_dm_id = dm_id;
416
417    let uri_str = format!("{}/v1/native/dm/{dmId}/messages", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
418    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
419
420    if let Some(ref user_agent) = configuration.user_agent {
421        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
422    }
423    if let Some(ref token) = configuration.bearer_access_token {
424        req_builder = req_builder.bearer_auth(token.to_owned());
425    };
426
427    let req = req_builder.build()?;
428    let resp = configuration.client.execute(req).await?;
429
430    let status = resp.status();
431    let content_type = resp
432        .headers()
433        .get("content-type")
434        .and_then(|v| v.to_str().ok())
435        .unwrap_or("application/octet-stream");
436    let content_type = super::ContentType::from(content_type);
437
438    if !status.is_client_error() && !status.is_server_error() {
439        let content = resp.text().await?;
440        match content_type {
441            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
442            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;`"))),
443            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;`")))),
444        }
445    } else {
446        let content = resp.text().await?;
447        let entity: Option<ListNativeDmMessagesError> = serde_json::from_str(&content).ok();
448        Err(Error::ResponseError(ResponseContent { status, content, entity }))
449    }
450}
451
452pub async fn list_native_dm_pinned_messages(configuration: &configuration::Configuration, dm_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListNativeDmPinnedMessagesError>> {
453    // add a prefix to parameters to efficiently prevent name collisions
454    let p_path_dm_id = dm_id;
455
456    let uri_str = format!("{}/v1/native/dm/{dmId}/pinned", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
457    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
458
459    if let Some(ref user_agent) = configuration.user_agent {
460        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
461    }
462    if let Some(ref token) = configuration.bearer_access_token {
463        req_builder = req_builder.bearer_auth(token.to_owned());
464    };
465
466    let req = req_builder.build()?;
467    let resp = configuration.client.execute(req).await?;
468
469    let status = resp.status();
470    let content_type = resp
471        .headers()
472        .get("content-type")
473        .and_then(|v| v.to_str().ok())
474        .unwrap_or("application/octet-stream");
475    let content_type = super::ContentType::from(content_type);
476
477    if !status.is_client_error() && !status.is_server_error() {
478        let content = resp.text().await?;
479        match content_type {
480            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
481            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;`"))),
482            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;`")))),
483        }
484    } else {
485        let content = resp.text().await?;
486        let entity: Option<ListNativeDmPinnedMessagesError> = serde_json::from_str(&content).ok();
487        Err(Error::ResponseError(ResponseContent { status, content, entity }))
488    }
489}
490
491pub async fn list_native_dm_thread_replies(configuration: &configuration::Configuration, dm_id: &str, message_id: &str) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<ListNativeDmThreadRepliesError>> {
492    // add a prefix to parameters to efficiently prevent name collisions
493    let p_path_dm_id = dm_id;
494    let p_path_message_id = message_id;
495
496    let uri_str = format!("{}/v1/native/dm/{dmId}/messages/{messageId}/replies", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id), messageId=crate::apis::urlencode(p_path_message_id));
497    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
498
499    if let Some(ref user_agent) = configuration.user_agent {
500        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
501    }
502    if let Some(ref token) = configuration.bearer_access_token {
503        req_builder = req_builder.bearer_auth(token.to_owned());
504    };
505
506    let req = req_builder.build()?;
507    let resp = configuration.client.execute(req).await?;
508
509    let status = resp.status();
510    let content_type = resp
511        .headers()
512        .get("content-type")
513        .and_then(|v| v.to_str().ok())
514        .unwrap_or("application/octet-stream");
515    let content_type = super::ContentType::from(content_type);
516
517    if !status.is_client_error() && !status.is_server_error() {
518        let content = resp.text().await?;
519        match content_type {
520            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
521            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;`"))),
522            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;`")))),
523        }
524    } else {
525        let content = resp.text().await?;
526        let entity: Option<ListNativeDmThreadRepliesError> = serde_json::from_str(&content).ok();
527        Err(Error::ResponseError(ResponseContent { status, content, entity }))
528    }
529}
530
531pub async fn mark_native_dm_read(configuration: &configuration::Configuration, dm_id: &str) -> Result<(), Error<MarkNativeDmReadError>> {
532    // add a prefix to parameters to efficiently prevent name collisions
533    let p_path_dm_id = dm_id;
534
535    let uri_str = format!("{}/v1/native/dm/{dmId}/read", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
536    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
537
538    if let Some(ref user_agent) = configuration.user_agent {
539        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
540    }
541    if let Some(ref token) = configuration.bearer_access_token {
542        req_builder = req_builder.bearer_auth(token.to_owned());
543    };
544
545    let req = req_builder.build()?;
546    let resp = configuration.client.execute(req).await?;
547
548    let status = resp.status();
549
550    if !status.is_client_error() && !status.is_server_error() {
551        Ok(())
552    } else {
553        let content = resp.text().await?;
554        let entity: Option<MarkNativeDmReadError> = serde_json::from_str(&content).ok();
555        Err(Error::ResponseError(ResponseContent { status, content, entity }))
556    }
557}
558
559pub async fn mute_native_dm(configuration: &configuration::Configuration, dm_id: &str, request_body: Option<std::collections::HashMap<String, serde_json::Value>>) -> Result<(), Error<MuteNativeDmError>> {
560    // add a prefix to parameters to efficiently prevent name collisions
561    let p_path_dm_id = dm_id;
562    let p_body_request_body = request_body;
563
564    let uri_str = format!("{}/v1/native/dm/{dmId}/mute", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
565    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
566
567    if let Some(ref user_agent) = configuration.user_agent {
568        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
569    }
570    if let Some(ref token) = configuration.bearer_access_token {
571        req_builder = req_builder.bearer_auth(token.to_owned());
572    };
573    req_builder = req_builder.json(&p_body_request_body);
574
575    let req = req_builder.build()?;
576    let resp = configuration.client.execute(req).await?;
577
578    let status = resp.status();
579
580    if !status.is_client_error() && !status.is_server_error() {
581        Ok(())
582    } else {
583        let content = resp.text().await?;
584        let entity: Option<MuteNativeDmError> = serde_json::from_str(&content).ok();
585        Err(Error::ResponseError(ResponseContent { status, content, entity }))
586    }
587}
588
589pub async fn pin_native_dm_conversation(configuration: &configuration::Configuration, dm_id: &str) -> Result<(), Error<PinNativeDmConversationError>> {
590    // add a prefix to parameters to efficiently prevent name collisions
591    let p_path_dm_id = dm_id;
592
593    let uri_str = format!("{}/v1/native/dm/{dmId}/pin", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
594    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
595
596    if let Some(ref user_agent) = configuration.user_agent {
597        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
598    }
599    if let Some(ref token) = configuration.bearer_access_token {
600        req_builder = req_builder.bearer_auth(token.to_owned());
601    };
602
603    let req = req_builder.build()?;
604    let resp = configuration.client.execute(req).await?;
605
606    let status = resp.status();
607
608    if !status.is_client_error() && !status.is_server_error() {
609        Ok(())
610    } else {
611        let content = resp.text().await?;
612        let entity: Option<PinNativeDmConversationError> = serde_json::from_str(&content).ok();
613        Err(Error::ResponseError(ResponseContent { status, content, entity }))
614    }
615}
616
617pub async fn pin_native_dm_message(configuration: &configuration::Configuration, message_id: &str) -> Result<(), Error<PinNativeDmMessageError>> {
618    // add a prefix to parameters to efficiently prevent name collisions
619    let p_path_message_id = message_id;
620
621    let uri_str = format!("{}/v1/native/dm/messages/{messageId}/pin", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
622    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
623
624    if let Some(ref user_agent) = configuration.user_agent {
625        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
626    }
627    if let Some(ref token) = configuration.bearer_access_token {
628        req_builder = req_builder.bearer_auth(token.to_owned());
629    };
630
631    let req = req_builder.build()?;
632    let resp = configuration.client.execute(req).await?;
633
634    let status = resp.status();
635
636    if !status.is_client_error() && !status.is_server_error() {
637        Ok(())
638    } else {
639        let content = resp.text().await?;
640        let entity: Option<PinNativeDmMessageError> = serde_json::from_str(&content).ok();
641        Err(Error::ResponseError(ResponseContent { status, content, entity }))
642    }
643}
644
645pub async fn post_native_dm_message(configuration: &configuration::Configuration, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<PostNativeDmMessageError>> {
646    // add a prefix to parameters to efficiently prevent name collisions
647    let p_body_request_body = request_body;
648
649    let uri_str = format!("{}/v1/native/dm", configuration.base_path);
650    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
651
652    if let Some(ref user_agent) = configuration.user_agent {
653        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
654    }
655    if let Some(ref token) = configuration.bearer_access_token {
656        req_builder = req_builder.bearer_auth(token.to_owned());
657    };
658    req_builder = req_builder.json(&p_body_request_body);
659
660    let req = req_builder.build()?;
661    let resp = configuration.client.execute(req).await?;
662
663    let status = resp.status();
664    let content_type = resp
665        .headers()
666        .get("content-type")
667        .and_then(|v| v.to_str().ok())
668        .unwrap_or("application/octet-stream");
669    let content_type = super::ContentType::from(content_type);
670
671    if !status.is_client_error() && !status.is_server_error() {
672        let content = resp.text().await?;
673        match content_type {
674            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
675            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;`"))),
676            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;`")))),
677        }
678    } else {
679        let content = resp.text().await?;
680        let entity: Option<PostNativeDmMessageError> = serde_json::from_str(&content).ok();
681        Err(Error::ResponseError(ResponseContent { status, content, entity }))
682    }
683}
684
685pub async fn post_native_dm_thread_reply(configuration: &configuration::Configuration, dm_id: &str, message_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<PostNativeDmThreadReplyError>> {
686    // add a prefix to parameters to efficiently prevent name collisions
687    let p_path_dm_id = dm_id;
688    let p_path_message_id = message_id;
689    let p_body_request_body = request_body;
690
691    let uri_str = format!("{}/v1/native/dm/{dmId}/messages/{messageId}/replies", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id), messageId=crate::apis::urlencode(p_path_message_id));
692    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
693
694    if let Some(ref user_agent) = configuration.user_agent {
695        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
696    }
697    if let Some(ref token) = configuration.bearer_access_token {
698        req_builder = req_builder.bearer_auth(token.to_owned());
699    };
700    req_builder = req_builder.json(&p_body_request_body);
701
702    let req = req_builder.build()?;
703    let resp = configuration.client.execute(req).await?;
704
705    let status = resp.status();
706    let content_type = resp
707        .headers()
708        .get("content-type")
709        .and_then(|v| v.to_str().ok())
710        .unwrap_or("application/octet-stream");
711    let content_type = super::ContentType::from(content_type);
712
713    if !status.is_client_error() && !status.is_server_error() {
714        let content = resp.text().await?;
715        match content_type {
716            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
717            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;`"))),
718            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;`")))),
719        }
720    } else {
721        let content = resp.text().await?;
722        let entity: Option<PostNativeDmThreadReplyError> = serde_json::from_str(&content).ok();
723        Err(Error::ResponseError(ResponseContent { status, content, entity }))
724    }
725}
726
727pub async fn remove_native_dm_reaction(configuration: &configuration::Configuration, message_id: &str, emoji: &str) -> Result<(), Error<RemoveNativeDmReactionError>> {
728    // add a prefix to parameters to efficiently prevent name collisions
729    let p_path_message_id = message_id;
730    let p_path_emoji = emoji;
731
732    let uri_str = format!("{}/v1/native/dm/messages/{messageId}/reactions/{emoji}", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id), emoji=crate::apis::urlencode(p_path_emoji));
733    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
734
735    if let Some(ref user_agent) = configuration.user_agent {
736        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
737    }
738    if let Some(ref token) = configuration.bearer_access_token {
739        req_builder = req_builder.bearer_auth(token.to_owned());
740    };
741
742    let req = req_builder.build()?;
743    let resp = configuration.client.execute(req).await?;
744
745    let status = resp.status();
746
747    if !status.is_client_error() && !status.is_server_error() {
748        Ok(())
749    } else {
750        let content = resp.text().await?;
751        let entity: Option<RemoveNativeDmReactionError> = serde_json::from_str(&content).ok();
752        Err(Error::ResponseError(ResponseContent { status, content, entity }))
753    }
754}
755
756pub async fn search_native_dm_messages(configuration: &configuration::Configuration, q: Option<&str>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<SearchNativeDmMessagesError>> {
757    // add a prefix to parameters to efficiently prevent name collisions
758    let p_query_q = q;
759
760    let uri_str = format!("{}/v1/native/dm/search", configuration.base_path);
761    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
762
763    if let Some(ref param_value) = p_query_q {
764        req_builder = req_builder.query(&[("q", &param_value.to_string())]);
765    }
766    if let Some(ref user_agent) = configuration.user_agent {
767        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
768    }
769    if let Some(ref token) = configuration.bearer_access_token {
770        req_builder = req_builder.bearer_auth(token.to_owned());
771    };
772
773    let req = req_builder.build()?;
774    let resp = configuration.client.execute(req).await?;
775
776    let status = resp.status();
777    let content_type = resp
778        .headers()
779        .get("content-type")
780        .and_then(|v| v.to_str().ok())
781        .unwrap_or("application/octet-stream");
782    let content_type = super::ContentType::from(content_type);
783
784    if !status.is_client_error() && !status.is_server_error() {
785        let content = resp.text().await?;
786        match content_type {
787            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
788            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;`"))),
789            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;`")))),
790        }
791    } else {
792        let content = resp.text().await?;
793        let entity: Option<SearchNativeDmMessagesError> = serde_json::from_str(&content).ok();
794        Err(Error::ResponseError(ResponseContent { status, content, entity }))
795    }
796}
797
798pub async fn set_native_dm_draft(configuration: &configuration::Configuration, dm_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<(), Error<SetNativeDmDraftError>> {
799    // add a prefix to parameters to efficiently prevent name collisions
800    let p_path_dm_id = dm_id;
801    let p_body_request_body = request_body;
802
803    let uri_str = format!("{}/v1/native/dm/{dmId}/draft", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
804    let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
805
806    if let Some(ref user_agent) = configuration.user_agent {
807        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
808    }
809    if let Some(ref token) = configuration.bearer_access_token {
810        req_builder = req_builder.bearer_auth(token.to_owned());
811    };
812    req_builder = req_builder.json(&p_body_request_body);
813
814    let req = req_builder.build()?;
815    let resp = configuration.client.execute(req).await?;
816
817    let status = resp.status();
818
819    if !status.is_client_error() && !status.is_server_error() {
820        Ok(())
821    } else {
822        let content = resp.text().await?;
823        let entity: Option<SetNativeDmDraftError> = serde_json::from_str(&content).ok();
824        Err(Error::ResponseError(ResponseContent { status, content, entity }))
825    }
826}
827
828pub async fn unpin_native_dm_conversation(configuration: &configuration::Configuration, dm_id: &str) -> Result<(), Error<UnpinNativeDmConversationError>> {
829    // add a prefix to parameters to efficiently prevent name collisions
830    let p_path_dm_id = dm_id;
831
832    let uri_str = format!("{}/v1/native/dm/{dmId}/pin", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id));
833    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
834
835    if let Some(ref user_agent) = configuration.user_agent {
836        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
837    }
838    if let Some(ref token) = configuration.bearer_access_token {
839        req_builder = req_builder.bearer_auth(token.to_owned());
840    };
841
842    let req = req_builder.build()?;
843    let resp = configuration.client.execute(req).await?;
844
845    let status = resp.status();
846
847    if !status.is_client_error() && !status.is_server_error() {
848        Ok(())
849    } else {
850        let content = resp.text().await?;
851        let entity: Option<UnpinNativeDmConversationError> = serde_json::from_str(&content).ok();
852        Err(Error::ResponseError(ResponseContent { status, content, entity }))
853    }
854}
855
856pub async fn unpin_native_dm_message(configuration: &configuration::Configuration, message_id: &str) -> Result<(), Error<UnpinNativeDmMessageError>> {
857    // add a prefix to parameters to efficiently prevent name collisions
858    let p_path_message_id = message_id;
859
860    let uri_str = format!("{}/v1/native/dm/messages/{messageId}/pin", configuration.base_path, messageId=crate::apis::urlencode(p_path_message_id));
861    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
862
863    if let Some(ref user_agent) = configuration.user_agent {
864        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
865    }
866    if let Some(ref token) = configuration.bearer_access_token {
867        req_builder = req_builder.bearer_auth(token.to_owned());
868    };
869
870    let req = req_builder.build()?;
871    let resp = configuration.client.execute(req).await?;
872
873    let status = resp.status();
874
875    if !status.is_client_error() && !status.is_server_error() {
876        Ok(())
877    } else {
878        let content = resp.text().await?;
879        let entity: Option<UnpinNativeDmMessageError> = serde_json::from_str(&content).ok();
880        Err(Error::ResponseError(ResponseContent { status, content, entity }))
881    }
882}
883
884pub async fn update_native_dm_message(configuration: &configuration::Configuration, dm_id: &str, message_id: &str, request_body: std::collections::HashMap<String, serde_json::Value>) -> Result<std::collections::HashMap<String, serde_json::Value>, Error<UpdateNativeDmMessageError>> {
885    // add a prefix to parameters to efficiently prevent name collisions
886    let p_path_dm_id = dm_id;
887    let p_path_message_id = message_id;
888    let p_body_request_body = request_body;
889
890    let uri_str = format!("{}/v1/native/dm/{dmId}/messages/{messageId}", configuration.base_path, dmId=crate::apis::urlencode(p_path_dm_id), messageId=crate::apis::urlencode(p_path_message_id));
891    let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &uri_str);
892
893    if let Some(ref user_agent) = configuration.user_agent {
894        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
895    }
896    if let Some(ref token) = configuration.bearer_access_token {
897        req_builder = req_builder.bearer_auth(token.to_owned());
898    };
899    req_builder = req_builder.json(&p_body_request_body);
900
901    let req = req_builder.build()?;
902    let resp = configuration.client.execute(req).await?;
903
904    let status = resp.status();
905    let content_type = resp
906        .headers()
907        .get("content-type")
908        .and_then(|v| v.to_str().ok())
909        .unwrap_or("application/octet-stream");
910    let content_type = super::ContentType::from(content_type);
911
912    if !status.is_client_error() && !status.is_server_error() {
913        let content = resp.text().await?;
914        match content_type {
915            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
916            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;`"))),
917            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;`")))),
918        }
919    } else {
920        let content = resp.text().await?;
921        let entity: Option<UpdateNativeDmMessageError> = serde_json::from_str(&content).ok();
922        Err(Error::ResponseError(ResponseContent { status, content, entity }))
923    }
924}
925