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