artcoded_api/apis/
menu_link_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 [`clicked`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum ClickedError {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`create_or_update`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum CreateOrUpdateError {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`delete4`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum Delete4Error {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`find_all11`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum FindAll11Error {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`import_all`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum ImportAllError {
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`top3`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum Top3Error {
55    UnknownValue(serde_json::Value),
56}
57
58pub async fn clicked(
59    configuration: &configuration::Configuration,
60    id: &str,
61) -> Result<(), Error<ClickedError>> {
62    // add a prefix to parameters to efficiently prevent name collisions
63    let p_query_id = id;
64
65    let uri_str = format!("{}/api/settings/menu-link/clicked", configuration.base_path);
66    let mut req_builder = configuration
67        .client
68        .request(reqwest::Method::POST, &uri_str);
69
70    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
71    if let Some(ref user_agent) = configuration.user_agent {
72        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
73    }
74    if let Some(ref token) = configuration.bearer_access_token {
75        req_builder = req_builder.bearer_auth(token.to_owned());
76    };
77
78    let req = req_builder.build()?;
79    let resp = configuration.client.execute(req).await?;
80
81    let status = resp.status();
82
83    if !status.is_client_error() && !status.is_server_error() {
84        Ok(())
85    } else {
86        let content = resp.text().await?;
87        let entity: Option<ClickedError> = serde_json::from_str(&content).ok();
88        Err(Error::ResponseError(ResponseContent {
89            status,
90            content,
91            entity,
92        }))
93    }
94}
95
96pub async fn create_or_update(
97    configuration: &configuration::Configuration,
98    menu_link: models::MenuLink,
99) -> Result<models::MenuLink, Error<CreateOrUpdateError>> {
100    // add a prefix to parameters to efficiently prevent name collisions
101    let p_body_menu_link = menu_link;
102
103    let uri_str = format!("{}/api/settings/menu-link/save", configuration.base_path);
104    let mut req_builder = configuration
105        .client
106        .request(reqwest::Method::POST, &uri_str);
107
108    if let Some(ref user_agent) = configuration.user_agent {
109        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
110    }
111    if let Some(ref token) = configuration.bearer_access_token {
112        req_builder = req_builder.bearer_auth(token.to_owned());
113    };
114    req_builder = req_builder.json(&p_body_menu_link);
115
116    let req = req_builder.build()?;
117    let resp = configuration.client.execute(req).await?;
118
119    let status = resp.status();
120    let content_type = resp
121        .headers()
122        .get("content-type")
123        .and_then(|v| v.to_str().ok())
124        .unwrap_or("application/octet-stream");
125    let content_type = super::ContentType::from(content_type);
126
127    if !status.is_client_error() && !status.is_server_error() {
128        let content = resp.text().await?;
129        match content_type {
130            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
131            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::MenuLink`"))),
132            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::MenuLink`")))),
133        }
134    } else {
135        let content = resp.text().await?;
136        let entity: Option<CreateOrUpdateError> = serde_json::from_str(&content).ok();
137        Err(Error::ResponseError(ResponseContent {
138            status,
139            content,
140            entity,
141        }))
142    }
143}
144
145pub async fn delete4(
146    configuration: &configuration::Configuration,
147    id: &str,
148) -> Result<(), Error<Delete4Error>> {
149    // add a prefix to parameters to efficiently prevent name collisions
150    let p_query_id = id;
151
152    let uri_str = format!("{}/api/settings/menu-link", configuration.base_path);
153    let mut req_builder = configuration
154        .client
155        .request(reqwest::Method::DELETE, &uri_str);
156
157    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
158    if let Some(ref user_agent) = configuration.user_agent {
159        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
160    }
161    if let Some(ref token) = configuration.bearer_access_token {
162        req_builder = req_builder.bearer_auth(token.to_owned());
163    };
164
165    let req = req_builder.build()?;
166    let resp = configuration.client.execute(req).await?;
167
168    let status = resp.status();
169
170    if !status.is_client_error() && !status.is_server_error() {
171        Ok(())
172    } else {
173        let content = resp.text().await?;
174        let entity: Option<Delete4Error> = serde_json::from_str(&content).ok();
175        Err(Error::ResponseError(ResponseContent {
176            status,
177            content,
178            entity,
179        }))
180    }
181}
182
183pub async fn find_all11(
184    configuration: &configuration::Configuration,
185) -> Result<Vec<models::MenuLink>, Error<FindAll11Error>> {
186    let uri_str = format!("{}/api/settings/menu-link", configuration.base_path);
187    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
188
189    if let Some(ref user_agent) = configuration.user_agent {
190        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
191    }
192    if let Some(ref token) = configuration.bearer_access_token {
193        req_builder = req_builder.bearer_auth(token.to_owned());
194    };
195
196    let req = req_builder.build()?;
197    let resp = configuration.client.execute(req).await?;
198
199    let status = resp.status();
200    let content_type = resp
201        .headers()
202        .get("content-type")
203        .and_then(|v| v.to_str().ok())
204        .unwrap_or("application/octet-stream");
205    let content_type = super::ContentType::from(content_type);
206
207    if !status.is_client_error() && !status.is_server_error() {
208        let content = resp.text().await?;
209        match content_type {
210            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
211            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MenuLink&gt;`"))),
212            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::MenuLink&gt;`")))),
213        }
214    } else {
215        let content = resp.text().await?;
216        let entity: Option<FindAll11Error> = serde_json::from_str(&content).ok();
217        Err(Error::ResponseError(ResponseContent {
218            status,
219            content,
220            entity,
221        }))
222    }
223}
224
225pub async fn import_all(
226    configuration: &configuration::Configuration,
227    menu_link: Vec<models::MenuLink>,
228) -> Result<(), Error<ImportAllError>> {
229    // add a prefix to parameters to efficiently prevent name collisions
230    let p_body_menu_link = menu_link;
231
232    let uri_str = format!("{}/api/settings/menu-link/import", configuration.base_path);
233    let mut req_builder = configuration
234        .client
235        .request(reqwest::Method::POST, &uri_str);
236
237    if let Some(ref user_agent) = configuration.user_agent {
238        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
239    }
240    if let Some(ref token) = configuration.bearer_access_token {
241        req_builder = req_builder.bearer_auth(token.to_owned());
242    };
243    req_builder = req_builder.json(&p_body_menu_link);
244
245    let req = req_builder.build()?;
246    let resp = configuration.client.execute(req).await?;
247
248    let status = resp.status();
249
250    if !status.is_client_error() && !status.is_server_error() {
251        Ok(())
252    } else {
253        let content = resp.text().await?;
254        let entity: Option<ImportAllError> = serde_json::from_str(&content).ok();
255        Err(Error::ResponseError(ResponseContent {
256            status,
257            content,
258            entity,
259        }))
260    }
261}
262
263pub async fn top3(
264    configuration: &configuration::Configuration,
265) -> Result<Vec<models::MenuLink>, Error<Top3Error>> {
266    let uri_str = format!("{}/api/settings/menu-link/top-3", configuration.base_path);
267    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
268
269    if let Some(ref user_agent) = configuration.user_agent {
270        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
271    }
272    if let Some(ref token) = configuration.bearer_access_token {
273        req_builder = req_builder.bearer_auth(token.to_owned());
274    };
275
276    let req = req_builder.build()?;
277    let resp = configuration.client.execute(req).await?;
278
279    let status = resp.status();
280    let content_type = resp
281        .headers()
282        .get("content-type")
283        .and_then(|v| v.to_str().ok())
284        .unwrap_or("application/octet-stream");
285    let content_type = super::ContentType::from(content_type);
286
287    if !status.is_client_error() && !status.is_server_error() {
288        let content = resp.text().await?;
289        match content_type {
290            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
291            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::MenuLink&gt;`"))),
292            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::MenuLink&gt;`")))),
293        }
294    } else {
295        let content = resp.text().await?;
296        let entity: Option<Top3Error> = serde_json::from_str(&content).ok();
297        Err(Error::ResponseError(ResponseContent {
298            status,
299            content,
300            entity,
301        }))
302    }
303}