artcoded_api/apis/
mail_controller_api.rs

1/*
2 * Artcoded
3 *
4 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5 *
6 * The version of the OpenAPI document: 1.0.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16/// struct for typed errors of method [`delete8`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Delete8Error {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`find_all13`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum FindAll13Error {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`send_mail`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum SendMailError {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`update1`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum Update1Error {
41    UnknownValue(serde_json::Value),
42}
43
44pub async fn delete8(
45    configuration: &configuration::Configuration,
46    id: &str,
47) -> Result<(), Error<Delete8Error>> {
48    // add a prefix to parameters to efficiently prevent name collisions
49    let p_query_id = id;
50
51    let uri_str = format!("{}/api/mail/delete", configuration.base_path);
52    let mut req_builder = configuration
53        .client
54        .request(reqwest::Method::DELETE, &uri_str);
55
56    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
57    if let Some(ref user_agent) = configuration.user_agent {
58        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
59    }
60    if let Some(ref token) = configuration.bearer_access_token {
61        req_builder = req_builder.bearer_auth(token.to_owned());
62    };
63
64    let req = req_builder.build()?;
65    let resp = configuration.client.execute(req).await?;
66
67    let status = resp.status();
68
69    if !status.is_client_error() && !status.is_server_error() {
70        Ok(())
71    } else {
72        let content = resp.text().await?;
73        let entity: Option<Delete8Error> = serde_json::from_str(&content).ok();
74        Err(Error::ResponseError(ResponseContent {
75            status,
76            content,
77            entity,
78        }))
79    }
80}
81
82pub async fn find_all13(
83    configuration: &configuration::Configuration,
84    arg0: models::Pageable,
85) -> Result<models::PagedModelMailJob, Error<FindAll13Error>> {
86    // add a prefix to parameters to efficiently prevent name collisions
87    let p_query_arg0 = arg0;
88
89    let uri_str = format!("{}/api/mail/find-all", configuration.base_path);
90    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
91
92    req_builder = req_builder.query(&[("arg0", &p_query_arg0.to_string())]);
93    if let Some(ref user_agent) = configuration.user_agent {
94        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
95    }
96    if let Some(ref token) = configuration.bearer_access_token {
97        req_builder = req_builder.bearer_auth(token.to_owned());
98    };
99
100    let req = req_builder.build()?;
101    let resp = configuration.client.execute(req).await?;
102
103    let status = resp.status();
104    let content_type = resp
105        .headers()
106        .get("content-type")
107        .and_then(|v| v.to_str().ok())
108        .unwrap_or("application/octet-stream");
109    let content_type = super::ContentType::from(content_type);
110
111    if !status.is_client_error() && !status.is_server_error() {
112        let content = resp.text().await?;
113        match content_type {
114            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
115            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedModelMailJob`"))),
116            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagedModelMailJob`")))),
117        }
118    } else {
119        let content = resp.text().await?;
120        let entity: Option<FindAll13Error> = serde_json::from_str(&content).ok();
121        Err(Error::ResponseError(ResponseContent {
122            status,
123            content,
124            entity,
125        }))
126    }
127}
128
129pub async fn send_mail(
130    configuration: &configuration::Configuration,
131    mail_request: models::MailRequest,
132) -> Result<(), Error<SendMailError>> {
133    // add a prefix to parameters to efficiently prevent name collisions
134    let p_body_mail_request = mail_request;
135
136    let uri_str = format!("{}/api/mail/send", configuration.base_path);
137    let mut req_builder = configuration
138        .client
139        .request(reqwest::Method::POST, &uri_str);
140
141    if let Some(ref user_agent) = configuration.user_agent {
142        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
143    }
144    if let Some(ref token) = configuration.bearer_access_token {
145        req_builder = req_builder.bearer_auth(token.to_owned());
146    };
147    req_builder = req_builder.json(&p_body_mail_request);
148
149    let req = req_builder.build()?;
150    let resp = configuration.client.execute(req).await?;
151
152    let status = resp.status();
153
154    if !status.is_client_error() && !status.is_server_error() {
155        Ok(())
156    } else {
157        let content = resp.text().await?;
158        let entity: Option<SendMailError> = serde_json::from_str(&content).ok();
159        Err(Error::ResponseError(ResponseContent {
160            status,
161            content,
162            entity,
163        }))
164    }
165}
166
167pub async fn update1(
168    configuration: &configuration::Configuration,
169    mail_job: models::MailJob,
170) -> Result<models::MailJob, Error<Update1Error>> {
171    // add a prefix to parameters to efficiently prevent name collisions
172    let p_body_mail_job = mail_job;
173
174    let uri_str = format!("{}/api/mail/update", configuration.base_path);
175    let mut req_builder = configuration
176        .client
177        .request(reqwest::Method::POST, &uri_str);
178
179    if let Some(ref user_agent) = configuration.user_agent {
180        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
181    }
182    if let Some(ref token) = configuration.bearer_access_token {
183        req_builder = req_builder.bearer_auth(token.to_owned());
184    };
185    req_builder = req_builder.json(&p_body_mail_job);
186
187    let req = req_builder.build()?;
188    let resp = configuration.client.execute(req).await?;
189
190    let status = resp.status();
191    let content_type = resp
192        .headers()
193        .get("content-type")
194        .and_then(|v| v.to_str().ok())
195        .unwrap_or("application/octet-stream");
196    let content_type = super::ContentType::from(content_type);
197
198    if !status.is_client_error() && !status.is_server_error() {
199        let content = resp.text().await?;
200        match content_type {
201            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
202            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MailJob`"))),
203            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MailJob`")))),
204        }
205    } else {
206        let content = resp.text().await?;
207        let entity: Option<Update1Error> = serde_json::from_str(&content).ok();
208        Err(Error::ResponseError(ResponseContent {
209            status,
210            content,
211            entity,
212        }))
213    }
214}