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