artcoded_api/apis/
form_contact_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 [`delete9`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Delete9Error {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`find_all4`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum FindAll4Error {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`submit`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum SubmitError {
34    UnknownValue(serde_json::Value),
35}
36
37pub async fn delete9(
38    configuration: &configuration::Configuration,
39    id: &str,
40) -> Result<models::Restore200Response, Error<Delete9Error>> {
41    // add a prefix to parameters to efficiently prevent name collisions
42    let p_query_id = id;
43
44    let uri_str = format!("{}/api/form-contact", configuration.base_path);
45    let mut req_builder = configuration
46        .client
47        .request(reqwest::Method::DELETE, &uri_str);
48
49    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
50    if let Some(ref user_agent) = configuration.user_agent {
51        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
52    }
53    if let Some(ref token) = configuration.bearer_access_token {
54        req_builder = req_builder.bearer_auth(token.to_owned());
55    };
56
57    let req = req_builder.build()?;
58    let resp = configuration.client.execute(req).await?;
59
60    let status = resp.status();
61    let content_type = resp
62        .headers()
63        .get("content-type")
64        .and_then(|v| v.to_str().ok())
65        .unwrap_or("application/octet-stream");
66    let content_type = super::ContentType::from(content_type);
67
68    if !status.is_client_error() && !status.is_server_error() {
69        let content = resp.text().await?;
70        match content_type {
71            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
72            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
73            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
74        }
75    } else {
76        let content = resp.text().await?;
77        let entity: Option<Delete9Error> = serde_json::from_str(&content).ok();
78        Err(Error::ResponseError(ResponseContent {
79            status,
80            content,
81            entity,
82        }))
83    }
84}
85
86pub async fn find_all4(
87    configuration: &configuration::Configuration,
88) -> Result<Vec<models::FormContact>, Error<FindAll4Error>> {
89    let uri_str = format!("{}/api/form-contact/find-all", configuration.base_path);
90    let mut req_builder = configuration
91        .client
92        .request(reqwest::Method::POST, &uri_str);
93
94    if let Some(ref user_agent) = configuration.user_agent {
95        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
96    }
97    if let Some(ref token) = configuration.bearer_access_token {
98        req_builder = req_builder.bearer_auth(token.to_owned());
99    };
100
101    let req = req_builder.build()?;
102    let resp = configuration.client.execute(req).await?;
103
104    let status = resp.status();
105    let content_type = resp
106        .headers()
107        .get("content-type")
108        .and_then(|v| v.to_str().ok())
109        .unwrap_or("application/octet-stream");
110    let content_type = super::ContentType::from(content_type);
111
112    if !status.is_client_error() && !status.is_server_error() {
113        let content = resp.text().await?;
114        match content_type {
115            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
116            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::FormContact&gt;`"))),
117            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::FormContact&gt;`")))),
118        }
119    } else {
120        let content = resp.text().await?;
121        let entity: Option<FindAll4Error> = serde_json::from_str(&content).ok();
122        Err(Error::ResponseError(ResponseContent {
123            status,
124            content,
125            entity,
126        }))
127    }
128}
129
130pub async fn submit(
131    configuration: &configuration::Configuration,
132    form_contact: models::FormContact,
133) -> Result<(), Error<SubmitError>> {
134    // add a prefix to parameters to efficiently prevent name collisions
135    let p_body_form_contact = form_contact;
136
137    let uri_str = format!("{}/api/form-contact/submit", configuration.base_path);
138    let mut req_builder = configuration
139        .client
140        .request(reqwest::Method::POST, &uri_str);
141
142    if let Some(ref user_agent) = configuration.user_agent {
143        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
144    }
145    if let Some(ref token) = configuration.bearer_access_token {
146        req_builder = req_builder.bearer_auth(token.to_owned());
147    };
148    req_builder = req_builder.json(&p_body_form_contact);
149
150    let req = req_builder.build()?;
151    let resp = configuration.client.execute(req).await?;
152
153    let status = resp.status();
154
155    if !status.is_client_error() && !status.is_server_error() {
156        Ok(())
157    } else {
158        let content = resp.text().await?;
159        let entity: Option<SubmitError> = serde_json::from_str(&content).ok();
160        Err(Error::ResponseError(ResponseContent {
161            status,
162            content,
163            entity,
164        }))
165    }
166}