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