1use super::{configuration, ContentType, Error};
12use crate::{apis::ResponseContent, models};
13use reqwest;
14use serde::{de::Error as _, Deserialize, Serialize};
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18#[serde(untagged)]
19pub enum AdminSearchError {
20 UnknownValue(serde_json::Value),
21}
22
23#[derive(Debug, Clone, Serialize, Deserialize)]
25#[serde(untagged)]
26pub enum Delete12Error {
27 UnknownValue(serde_json::Value),
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
32#[serde(untagged)]
33pub enum GeneratePdfError {
34 UnknownValue(serde_json::Value),
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(untagged)]
40pub enum GetLatestError {
41 UnknownValue(serde_json::Value),
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46#[serde(untagged)]
47pub enum GetPostByIdError {
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum GetPublicPostByIdError {
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum GetTagsError {
62 UnknownValue(serde_json::Value),
63}
64
65#[derive(Debug, Clone, Serialize, Deserialize)]
67#[serde(untagged)]
68pub enum NewPostError {
69 UnknownValue(serde_json::Value),
70}
71
72#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum PublicSearchError {
76 UnknownValue(serde_json::Value),
77}
78
79#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(untagged)]
82pub enum ResetPostCountError {
83 UnknownValue(serde_json::Value),
84}
85
86#[derive(Debug, Clone, Serialize, Deserialize)]
88#[serde(untagged)]
89pub enum Save6Error {
90 UnknownValue(serde_json::Value),
91}
92
93pub async fn admin_search(
94 configuration: &configuration::Configuration,
95 arg1: models::Pageable,
96 post_search_criteria: models::PostSearchCriteria,
97) -> Result<models::PagedModelPost, Error<AdminSearchError>> {
98 let p_query_arg1 = arg1;
100 let p_body_post_search_criteria = post_search_criteria;
101
102 let uri_str = format!("{}/api/blog/admin-search", configuration.base_path);
103 let mut req_builder = configuration
104 .client
105 .request(reqwest::Method::POST, &uri_str);
106
107 req_builder = req_builder.query(&[("arg1", &p_query_arg1.to_string())]);
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_post_search_criteria);
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::PagedModelPost`"))),
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::PagedModelPost`")))),
133 }
134 } else {
135 let content = resp.text().await?;
136 let entity: Option<AdminSearchError> = serde_json::from_str(&content).ok();
137 Err(Error::ResponseError(ResponseContent {
138 status,
139 content,
140 entity,
141 }))
142 }
143}
144
145pub async fn delete12(
146 configuration: &configuration::Configuration,
147 id: &str,
148) -> Result<models::Restore200Response, Error<Delete12Error>> {
149 let p_query_id = id;
151
152 let uri_str = format!("{}/api/blog", 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 let content_type = resp
170 .headers()
171 .get("content-type")
172 .and_then(|v| v.to_str().ok())
173 .unwrap_or("application/octet-stream");
174 let content_type = super::ContentType::from(content_type);
175
176 if !status.is_client_error() && !status.is_server_error() {
177 let content = resp.text().await?;
178 match content_type {
179 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
180 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Restore200Response`"))),
181 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Restore200Response`")))),
182 }
183 } else {
184 let content = resp.text().await?;
185 let entity: Option<Delete12Error> = serde_json::from_str(&content).ok();
186 Err(Error::ResponseError(ResponseContent {
187 status,
188 content,
189 entity,
190 }))
191 }
192}
193
194pub async fn generate_pdf(
195 configuration: &configuration::Configuration,
196 id: &str,
197) -> Result<reqwest::Response, Error<GeneratePdfError>> {
198 let p_query_id = id;
200
201 let uri_str = format!("{}/api/blog/generate-pdf", configuration.base_path);
202 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
203
204 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
205 if let Some(ref user_agent) = configuration.user_agent {
206 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
207 }
208 if let Some(ref token) = configuration.bearer_access_token {
209 req_builder = req_builder.bearer_auth(token.to_owned());
210 };
211
212 let req = req_builder.build()?;
213 let resp = configuration.client.execute(req).await?;
214
215 let status = resp.status();
216
217 if !status.is_client_error() && !status.is_server_error() {
218 Ok(resp)
219 } else {
220 let content = resp.text().await?;
221 let entity: Option<GeneratePdfError> = serde_json::from_str(&content).ok();
222 Err(Error::ResponseError(ResponseContent {
223 status,
224 content,
225 entity,
226 }))
227 }
228}
229
230pub async fn get_latest(
231 configuration: &configuration::Configuration,
232) -> Result<models::PagedModelPost, Error<GetLatestError>> {
233 let uri_str = format!("{}/api/blog/latest", configuration.base_path);
234 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
235
236 if let Some(ref user_agent) = configuration.user_agent {
237 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
238 }
239 if let Some(ref token) = configuration.bearer_access_token {
240 req_builder = req_builder.bearer_auth(token.to_owned());
241 };
242
243 let req = req_builder.build()?;
244 let resp = configuration.client.execute(req).await?;
245
246 let status = resp.status();
247 let content_type = resp
248 .headers()
249 .get("content-type")
250 .and_then(|v| v.to_str().ok())
251 .unwrap_or("application/octet-stream");
252 let content_type = super::ContentType::from(content_type);
253
254 if !status.is_client_error() && !status.is_server_error() {
255 let content = resp.text().await?;
256 match content_type {
257 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
258 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedModelPost`"))),
259 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagedModelPost`")))),
260 }
261 } else {
262 let content = resp.text().await?;
263 let entity: Option<GetLatestError> = serde_json::from_str(&content).ok();
264 Err(Error::ResponseError(ResponseContent {
265 status,
266 content,
267 entity,
268 }))
269 }
270}
271
272pub async fn get_post_by_id(
273 configuration: &configuration::Configuration,
274 id: &str,
275) -> Result<models::Post, Error<GetPostByIdError>> {
276 let p_query_id = id;
278
279 let uri_str = format!("{}/api/blog/post-by-id", configuration.base_path);
280 let mut req_builder = configuration
281 .client
282 .request(reqwest::Method::POST, &uri_str);
283
284 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
285 if let Some(ref user_agent) = configuration.user_agent {
286 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
287 }
288 if let Some(ref token) = configuration.bearer_access_token {
289 req_builder = req_builder.bearer_auth(token.to_owned());
290 };
291
292 let req = req_builder.build()?;
293 let resp = configuration.client.execute(req).await?;
294
295 let status = resp.status();
296 let content_type = resp
297 .headers()
298 .get("content-type")
299 .and_then(|v| v.to_str().ok())
300 .unwrap_or("application/octet-stream");
301 let content_type = super::ContentType::from(content_type);
302
303 if !status.is_client_error() && !status.is_server_error() {
304 let content = resp.text().await?;
305 match content_type {
306 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
307 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Post`"))),
308 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Post`")))),
309 }
310 } else {
311 let content = resp.text().await?;
312 let entity: Option<GetPostByIdError> = serde_json::from_str(&content).ok();
313 Err(Error::ResponseError(ResponseContent {
314 status,
315 content,
316 entity,
317 }))
318 }
319}
320
321pub async fn get_public_post_by_id(
322 configuration: &configuration::Configuration,
323 title: &str,
324 id: &str,
325) -> Result<models::Post, Error<GetPublicPostByIdError>> {
326 let p_path_title = title;
328 let p_path_id = id;
329
330 let uri_str = format!(
331 "{}/api/blog/post/{title}/{id}",
332 configuration.base_path,
333 title = crate::apis::urlencode(p_path_title),
334 id = crate::apis::urlencode(p_path_id)
335 );
336 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
337
338 if let Some(ref user_agent) = configuration.user_agent {
339 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
340 }
341 if let Some(ref token) = configuration.bearer_access_token {
342 req_builder = req_builder.bearer_auth(token.to_owned());
343 };
344
345 let req = req_builder.build()?;
346 let resp = configuration.client.execute(req).await?;
347
348 let status = resp.status();
349 let content_type = resp
350 .headers()
351 .get("content-type")
352 .and_then(|v| v.to_str().ok())
353 .unwrap_or("application/octet-stream");
354 let content_type = super::ContentType::from(content_type);
355
356 if !status.is_client_error() && !status.is_server_error() {
357 let content = resp.text().await?;
358 match content_type {
359 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
360 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Post`"))),
361 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Post`")))),
362 }
363 } else {
364 let content = resp.text().await?;
365 let entity: Option<GetPublicPostByIdError> = serde_json::from_str(&content).ok();
366 Err(Error::ResponseError(ResponseContent {
367 status,
368 content,
369 entity,
370 }))
371 }
372}
373
374pub async fn get_tags(
375 configuration: &configuration::Configuration,
376) -> Result<Vec<String>, Error<GetTagsError>> {
377 let uri_str = format!("{}/api/blog/tags", configuration.base_path);
378 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
379
380 if let Some(ref user_agent) = configuration.user_agent {
381 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
382 }
383 if let Some(ref token) = configuration.bearer_access_token {
384 req_builder = req_builder.bearer_auth(token.to_owned());
385 };
386
387 let req = req_builder.build()?;
388 let resp = configuration.client.execute(req).await?;
389
390 let status = resp.status();
391 let content_type = resp
392 .headers()
393 .get("content-type")
394 .and_then(|v| v.to_str().ok())
395 .unwrap_or("application/octet-stream");
396 let content_type = super::ContentType::from(content_type);
397
398 if !status.is_client_error() && !status.is_server_error() {
399 let content = resp.text().await?;
400 match content_type {
401 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
402 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<String>`"))),
403 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<String>`")))),
404 }
405 } else {
406 let content = resp.text().await?;
407 let entity: Option<GetTagsError> = serde_json::from_str(&content).ok();
408 Err(Error::ResponseError(ResponseContent {
409 status,
410 content,
411 entity,
412 }))
413 }
414}
415
416pub async fn new_post(
417 configuration: &configuration::Configuration,
418) -> Result<models::Post, Error<NewPostError>> {
419 let uri_str = format!("{}/api/blog/new-post", configuration.base_path);
420 let mut req_builder = configuration
421 .client
422 .request(reqwest::Method::POST, &uri_str);
423
424 if let Some(ref user_agent) = configuration.user_agent {
425 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
426 }
427 if let Some(ref token) = configuration.bearer_access_token {
428 req_builder = req_builder.bearer_auth(token.to_owned());
429 };
430
431 let req = req_builder.build()?;
432 let resp = configuration.client.execute(req).await?;
433
434 let status = resp.status();
435 let content_type = resp
436 .headers()
437 .get("content-type")
438 .and_then(|v| v.to_str().ok())
439 .unwrap_or("application/octet-stream");
440 let content_type = super::ContentType::from(content_type);
441
442 if !status.is_client_error() && !status.is_server_error() {
443 let content = resp.text().await?;
444 match content_type {
445 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
446 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Post`"))),
447 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Post`")))),
448 }
449 } else {
450 let content = resp.text().await?;
451 let entity: Option<NewPostError> = serde_json::from_str(&content).ok();
452 Err(Error::ResponseError(ResponseContent {
453 status,
454 content,
455 entity,
456 }))
457 }
458}
459
460pub async fn public_search(
461 configuration: &configuration::Configuration,
462 arg1: models::Pageable,
463 post_search_criteria: models::PostSearchCriteria,
464) -> Result<models::PagedModelPost, Error<PublicSearchError>> {
465 let p_query_arg1 = arg1;
467 let p_body_post_search_criteria = post_search_criteria;
468
469 let uri_str = format!("{}/api/blog/public-search", configuration.base_path);
470 let mut req_builder = configuration
471 .client
472 .request(reqwest::Method::POST, &uri_str);
473
474 req_builder = req_builder.query(&[("arg1", &p_query_arg1.to_string())]);
475 if let Some(ref user_agent) = configuration.user_agent {
476 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
477 }
478 if let Some(ref token) = configuration.bearer_access_token {
479 req_builder = req_builder.bearer_auth(token.to_owned());
480 };
481 req_builder = req_builder.json(&p_body_post_search_criteria);
482
483 let req = req_builder.build()?;
484 let resp = configuration.client.execute(req).await?;
485
486 let status = resp.status();
487 let content_type = resp
488 .headers()
489 .get("content-type")
490 .and_then(|v| v.to_str().ok())
491 .unwrap_or("application/octet-stream");
492 let content_type = super::ContentType::from(content_type);
493
494 if !status.is_client_error() && !status.is_server_error() {
495 let content = resp.text().await?;
496 match content_type {
497 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
498 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PagedModelPost`"))),
499 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::PagedModelPost`")))),
500 }
501 } else {
502 let content = resp.text().await?;
503 let entity: Option<PublicSearchError> = serde_json::from_str(&content).ok();
504 Err(Error::ResponseError(ResponseContent {
505 status,
506 content,
507 entity,
508 }))
509 }
510}
511
512pub async fn reset_post_count(
513 configuration: &configuration::Configuration,
514 id: &str,
515) -> Result<(), Error<ResetPostCountError>> {
516 let p_path_id = id;
518
519 let uri_str = format!(
520 "{}/api/blog/post/{id}/reset-count",
521 configuration.base_path,
522 id = crate::apis::urlencode(p_path_id)
523 );
524 let mut req_builder = configuration
525 .client
526 .request(reqwest::Method::POST, &uri_str);
527
528 if let Some(ref user_agent) = configuration.user_agent {
529 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
530 }
531 if let Some(ref token) = configuration.bearer_access_token {
532 req_builder = req_builder.bearer_auth(token.to_owned());
533 };
534
535 let req = req_builder.build()?;
536 let resp = configuration.client.execute(req).await?;
537
538 let status = resp.status();
539
540 if !status.is_client_error() && !status.is_server_error() {
541 Ok(())
542 } else {
543 let content = resp.text().await?;
544 let entity: Option<ResetPostCountError> = serde_json::from_str(&content).ok();
545 Err(Error::ResponseError(ResponseContent {
546 status,
547 content,
548 entity,
549 }))
550 }
551}
552
553pub async fn save6(
554 configuration: &configuration::Configuration,
555 id: &str,
556 title: &str,
557 description: &str,
558 tags: Vec<String>,
559 content: &str,
560 draft: Option<bool>,
561 cover: Option<std::path::PathBuf>,
562) -> Result<models::Post, Error<Save6Error>> {
563 let p_query_id = id;
565 let p_query_title = title;
566 let p_query_description = description;
567 let p_query_tags = tags;
568 let p_query_content = content;
569 let p_query_draft = draft;
570 let p_form_cover = cover;
571
572 let uri_str = format!("{}/api/blog/submit", configuration.base_path);
573 let mut req_builder = configuration
574 .client
575 .request(reqwest::Method::POST, &uri_str);
576
577 req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
578 req_builder = req_builder.query(&[("title", &p_query_title.to_string())]);
579 req_builder = req_builder.query(&[("description", &p_query_description.to_string())]);
580 req_builder = match "multi" {
581 "multi" => req_builder.query(
582 &p_query_tags
583 .into_iter()
584 .map(|p| ("tags".to_owned(), p.to_string()))
585 .collect::<Vec<(std::string::String, std::string::String)>>(),
586 ),
587 _ => req_builder.query(&[(
588 "tags",
589 &p_query_tags
590 .into_iter()
591 .map(|p| p.to_string())
592 .collect::<Vec<String>>()
593 .join(",")
594 .to_string(),
595 )]),
596 };
597 req_builder = req_builder.query(&[("content", &p_query_content.to_string())]);
598 if let Some(ref param_value) = p_query_draft {
599 req_builder = req_builder.query(&[("draft", ¶m_value.to_string())]);
600 }
601 if let Some(ref user_agent) = configuration.user_agent {
602 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
603 }
604 if let Some(ref token) = configuration.bearer_access_token {
605 req_builder = req_builder.bearer_auth(token.to_owned());
606 };
607 let multipart_form = reqwest::multipart::Form::new();
608 req_builder = req_builder.multipart(multipart_form);
610
611 let req = req_builder.build()?;
612 let resp = configuration.client.execute(req).await?;
613
614 let status = resp.status();
615 let content_type = resp
616 .headers()
617 .get("content-type")
618 .and_then(|v| v.to_str().ok())
619 .unwrap_or("application/octet-stream");
620 let content_type = super::ContentType::from(content_type);
621
622 if !status.is_client_error() && !status.is_server_error() {
623 let content = resp.text().await?;
624 match content_type {
625 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
626 ContentType::Text => Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Post`"))),
627 ContentType::Unsupported(unknown_type) => Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Post`")))),
628 }
629 } else {
630 let content = resp.text().await?;
631 let entity: Option<Save6Error> = serde_json::from_str(&content).ok();
632 Err(Error::ResponseError(ResponseContent {
633 status,
634 content,
635 entity,
636 }))
637 }
638}