artcoded_api/apis/
administrative_documen_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 [`delete14`]
17#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum Delete14Error {
20    UnknownValue(serde_json::Value),
21}
22
23/// struct for typed errors of method [`find_all10`]
24#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum FindAll10Error {
27    UnknownValue(serde_json::Value),
28}
29
30/// struct for typed errors of method [`find_by_id4`]
31#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum FindById4Error {
34    UnknownValue(serde_json::Value),
35}
36
37/// struct for typed errors of method [`find_by_ids3`]
38#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum FindByIds3Error {
41    UnknownValue(serde_json::Value),
42}
43
44/// struct for typed errors of method [`save8`]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum Save8Error {
48    UnknownValue(serde_json::Value),
49}
50
51/// struct for typed errors of method [`search`]
52#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum SearchError {
55    UnknownValue(serde_json::Value),
56}
57
58/// struct for typed errors of method [`toggle_bookmarked4`]
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum ToggleBookmarked4Error {
62    UnknownValue(serde_json::Value),
63}
64
65pub async fn delete14(
66    configuration: &configuration::Configuration,
67    id: &str,
68) -> Result<(), Error<Delete14Error>> {
69    // add a prefix to parameters to efficiently prevent name collisions
70    let p_query_id = id;
71
72    let uri_str = format!("{}/api/administrative-document", configuration.base_path);
73    let mut req_builder = configuration
74        .client
75        .request(reqwest::Method::DELETE, &uri_str);
76
77    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
78    if let Some(ref user_agent) = configuration.user_agent {
79        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
80    }
81    if let Some(ref token) = configuration.bearer_access_token {
82        req_builder = req_builder.bearer_auth(token.to_owned());
83    };
84
85    let req = req_builder.build()?;
86    let resp = configuration.client.execute(req).await?;
87
88    let status = resp.status();
89
90    if !status.is_client_error() && !status.is_server_error() {
91        Ok(())
92    } else {
93        let content = resp.text().await?;
94        let entity: Option<Delete14Error> = serde_json::from_str(&content).ok();
95        Err(Error::ResponseError(ResponseContent {
96            status,
97            content,
98            entity,
99        }))
100    }
101}
102
103pub async fn find_all10(
104    configuration: &configuration::Configuration,
105) -> Result<Vec<models::AdministrativeDocument>, Error<FindAll10Error>> {
106    let uri_str = format!(
107        "{}/api/administrative-document/find-all",
108        configuration.base_path
109    );
110    let mut req_builder = configuration
111        .client
112        .request(reqwest::Method::POST, &uri_str);
113
114    if let Some(ref user_agent) = configuration.user_agent {
115        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
116    }
117    if let Some(ref token) = configuration.bearer_access_token {
118        req_builder = req_builder.bearer_auth(token.to_owned());
119    };
120
121    let req = req_builder.build()?;
122    let resp = configuration.client.execute(req).await?;
123
124    let status = resp.status();
125    let content_type = resp
126        .headers()
127        .get("content-type")
128        .and_then(|v| v.to_str().ok())
129        .unwrap_or("application/octet-stream");
130    let content_type = super::ContentType::from(content_type);
131
132    if !status.is_client_error() && !status.is_server_error() {
133        let content = resp.text().await?;
134        match content_type {
135            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
136            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::AdministrativeDocument&gt;`"))),
137            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::AdministrativeDocument&gt;`")))),
138        }
139    } else {
140        let content = resp.text().await?;
141        let entity: Option<FindAll10Error> = serde_json::from_str(&content).ok();
142        Err(Error::ResponseError(ResponseContent {
143            status,
144            content,
145            entity,
146        }))
147    }
148}
149
150pub async fn find_by_id4(
151    configuration: &configuration::Configuration,
152    id: &str,
153) -> Result<models::AdministrativeDocument, Error<FindById4Error>> {
154    // add a prefix to parameters to efficiently prevent name collisions
155    let p_query_id = id;
156
157    let uri_str = format!(
158        "{}/api/administrative-document/find-by-id",
159        configuration.base_path
160    );
161    let mut req_builder = configuration
162        .client
163        .request(reqwest::Method::POST, &uri_str);
164
165    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
166    if let Some(ref user_agent) = configuration.user_agent {
167        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
168    }
169    if let Some(ref token) = configuration.bearer_access_token {
170        req_builder = req_builder.bearer_auth(token.to_owned());
171    };
172
173    let req = req_builder.build()?;
174    let resp = configuration.client.execute(req).await?;
175
176    let status = resp.status();
177    let content_type = resp
178        .headers()
179        .get("content-type")
180        .and_then(|v| v.to_str().ok())
181        .unwrap_or("application/octet-stream");
182    let content_type = super::ContentType::from(content_type);
183
184    if !status.is_client_error() && !status.is_server_error() {
185        let content = resp.text().await?;
186        match content_type {
187            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
188            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdministrativeDocument`"))),
189            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdministrativeDocument`")))),
190        }
191    } else {
192        let content = resp.text().await?;
193        let entity: Option<FindById4Error> = serde_json::from_str(&content).ok();
194        Err(Error::ResponseError(ResponseContent {
195            status,
196            content,
197            entity,
198        }))
199    }
200}
201
202pub async fn find_by_ids3(
203    configuration: &configuration::Configuration,
204    id: Vec<String>,
205) -> Result<Vec<models::AdministrativeDocument>, Error<FindByIds3Error>> {
206    // add a prefix to parameters to efficiently prevent name collisions
207    let p_query_id = id;
208
209    let uri_str = format!(
210        "{}/api/administrative-document/find-by-ids",
211        configuration.base_path
212    );
213    let mut req_builder = configuration
214        .client
215        .request(reqwest::Method::POST, &uri_str);
216
217    req_builder = match "multi" {
218        "multi" => req_builder.query(
219            &p_query_id
220                .into_iter()
221                .map(|p| ("id".to_owned(), p.to_string()))
222                .collect::<Vec<(std::string::String, std::string::String)>>(),
223        ),
224        _ => req_builder.query(&[(
225            "id",
226            &p_query_id
227                .into_iter()
228                .map(|p| p.to_string())
229                .collect::<Vec<String>>()
230                .join(",")
231                .to_string(),
232        )]),
233    };
234    if let Some(ref user_agent) = configuration.user_agent {
235        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
236    }
237    if let Some(ref token) = configuration.bearer_access_token {
238        req_builder = req_builder.bearer_auth(token.to_owned());
239    };
240
241    let req = req_builder.build()?;
242    let resp = configuration.client.execute(req).await?;
243
244    let status = resp.status();
245    let content_type = resp
246        .headers()
247        .get("content-type")
248        .and_then(|v| v.to_str().ok())
249        .unwrap_or("application/octet-stream");
250    let content_type = super::ContentType::from(content_type);
251
252    if !status.is_client_error() && !status.is_server_error() {
253        let content = resp.text().await?;
254        match content_type {
255            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
256            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::AdministrativeDocument&gt;`"))),
257            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::AdministrativeDocument&gt;`")))),
258        }
259    } else {
260        let content = resp.text().await?;
261        let entity: Option<FindByIds3Error> = serde_json::from_str(&content).ok();
262        Err(Error::ResponseError(ResponseContent {
263            status,
264            content,
265            entity,
266        }))
267    }
268}
269
270pub async fn save8(
271    configuration: &configuration::Configuration,
272    title: &str,
273    id: Option<&str>,
274    description: Option<&str>,
275    tags: Option<Vec<String>>,
276    document: Option<std::path::PathBuf>,
277) -> Result<(), Error<Save8Error>> {
278    // add a prefix to parameters to efficiently prevent name collisions
279    let p_query_title = title;
280    let p_query_id = id;
281    let p_query_description = description;
282    let p_query_tags = tags;
283    let p_form_document = document;
284
285    let uri_str = format!(
286        "{}/api/administrative-document/save",
287        configuration.base_path
288    );
289    let mut req_builder = configuration
290        .client
291        .request(reqwest::Method::POST, &uri_str);
292
293    req_builder = req_builder.query(&[("title", &p_query_title.to_string())]);
294    if let Some(ref param_value) = p_query_id {
295        req_builder = req_builder.query(&[("id", &param_value.to_string())]);
296    }
297    if let Some(ref param_value) = p_query_description {
298        req_builder = req_builder.query(&[("description", &param_value.to_string())]);
299    }
300    if let Some(ref param_value) = p_query_tags {
301        req_builder = match "multi" {
302            "multi" => req_builder.query(
303                &param_value
304                    .iter()
305                    .map(|p| ("tags".to_owned(), p.to_string()))
306                    .collect::<Vec<(std::string::String, std::string::String)>>(),
307            ),
308            _ => req_builder.query(&[(
309                "tags",
310                &param_value
311                    .iter()
312                    .map(|p| p.to_string())
313                    .collect::<Vec<String>>()
314                    .join(",")
315                    .to_string(),
316            )]),
317        };
318    }
319    if let Some(ref user_agent) = configuration.user_agent {
320        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
321    }
322    if let Some(ref token) = configuration.bearer_access_token {
323        req_builder = req_builder.bearer_auth(token.to_owned());
324    };
325    let multipart_form = reqwest::multipart::Form::new();
326    // TODO: support file upload for 'document' parameter
327    req_builder = req_builder.multipart(multipart_form);
328
329    let req = req_builder.build()?;
330    let resp = configuration.client.execute(req).await?;
331
332    let status = resp.status();
333
334    if !status.is_client_error() && !status.is_server_error() {
335        Ok(())
336    } else {
337        let content = resp.text().await?;
338        let entity: Option<Save8Error> = serde_json::from_str(&content).ok();
339        Err(Error::ResponseError(ResponseContent {
340            status,
341            content,
342            entity,
343        }))
344    }
345}
346
347pub async fn search(
348    configuration: &configuration::Configuration,
349    arg1: models::Pageable,
350    administrative_document_search_criteria: models::AdministrativeDocumentSearchCriteria,
351) -> Result<models::PagedModelAdministrativeDocument, Error<SearchError>> {
352    // add a prefix to parameters to efficiently prevent name collisions
353    let p_query_arg1 = arg1;
354    let p_body_administrative_document_search_criteria = administrative_document_search_criteria;
355
356    let uri_str = format!(
357        "{}/api/administrative-document/search",
358        configuration.base_path
359    );
360    let mut req_builder = configuration
361        .client
362        .request(reqwest::Method::POST, &uri_str);
363
364    req_builder = req_builder.query(&[("arg1", &p_query_arg1.to_string())]);
365    if let Some(ref user_agent) = configuration.user_agent {
366        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
367    }
368    if let Some(ref token) = configuration.bearer_access_token {
369        req_builder = req_builder.bearer_auth(token.to_owned());
370    };
371    req_builder = req_builder.json(&p_body_administrative_document_search_criteria);
372
373    let req = req_builder.build()?;
374    let resp = configuration.client.execute(req).await?;
375
376    let status = resp.status();
377    let content_type = resp
378        .headers()
379        .get("content-type")
380        .and_then(|v| v.to_str().ok())
381        .unwrap_or("application/octet-stream");
382    let content_type = super::ContentType::from(content_type);
383
384    if !status.is_client_error() && !status.is_server_error() {
385        let content = resp.text().await?;
386        match content_type {
387            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
388            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedModelAdministrativeDocument`"))),
389            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagedModelAdministrativeDocument`")))),
390        }
391    } else {
392        let content = resp.text().await?;
393        let entity: Option<SearchError> = serde_json::from_str(&content).ok();
394        Err(Error::ResponseError(ResponseContent {
395            status,
396            content,
397            entity,
398        }))
399    }
400}
401
402pub async fn toggle_bookmarked4(
403    configuration: &configuration::Configuration,
404    id: &str,
405) -> Result<models::AdministrativeDocument, Error<ToggleBookmarked4Error>> {
406    // add a prefix to parameters to efficiently prevent name collisions
407    let p_query_id = id;
408
409    let uri_str = format!(
410        "{}/api/administrative-document/toggle-bookmarked",
411        configuration.base_path
412    );
413    let mut req_builder = configuration
414        .client
415        .request(reqwest::Method::POST, &uri_str);
416
417    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
418    if let Some(ref user_agent) = configuration.user_agent {
419        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
420    }
421    if let Some(ref token) = configuration.bearer_access_token {
422        req_builder = req_builder.bearer_auth(token.to_owned());
423    };
424
425    let req = req_builder.build()?;
426    let resp = configuration.client.execute(req).await?;
427
428    let status = resp.status();
429    let content_type = resp
430        .headers()
431        .get("content-type")
432        .and_then(|v| v.to_str().ok())
433        .unwrap_or("application/octet-stream");
434    let content_type = super::ContentType::from(content_type);
435
436    if !status.is_client_error() && !status.is_server_error() {
437        let content = resp.text().await?;
438        match content_type {
439            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
440            ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::AdministrativeDocument`"))),
441            ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::AdministrativeDocument`")))),
442        }
443    } else {
444        let content = resp.text().await?;
445        let entity: Option<ToggleBookmarked4Error> = serde_json::from_str(&content).ok();
446        Err(Error::ResponseError(ResponseContent {
447            status,
448            content,
449            entity,
450        }))
451    }
452}