1use reqwest;
12#[allow(unused_imports)]
13use serde::{de::Error as _};
14use crate::{apis::ResponseContent, models};
15#[allow(unused_imports)]
16use super::{Error, ContentType};
17use dtz_config::Configuration;
18
19fn build_url(config: &Configuration) -> String {
20 if let Some(base_path) = &config.base_path {
21 let base = url::Url::parse(base_path).unwrap();
22 let mut target_url = url::Url::parse(crate::apis::SVC_URL).unwrap();
23 let _ = target_url.set_scheme(base.scheme());
24 let _ = target_url.set_port(base.port());
25 let _ = target_url.set_host(Some(base.host_str().unwrap()));
26 format!("{target_url}")
27 } else {
28 crate::apis::SVC_URL.to_string()
29 }
30}
31
32
33#[derive(Debug, Clone, Serialize, Deserialize)]
35#[serde(untagged)]
36pub enum CreateFeedError {
37 Status401(models::ErrorMessage),
38 Status500(models::ErrorMessage),
39 UnknownValue(serde_json::Value),
40}
41
42#[derive(Debug, Clone, Serialize, Deserialize)]
44#[serde(untagged)]
45pub enum DeleteFeedError {
46 Status401(models::ErrorMessage),
47 Status500(models::ErrorMessage),
48 UnknownValue(serde_json::Value),
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53#[serde(untagged)]
54pub enum DisableFeedError {
55 Status401(models::ErrorMessage),
56 Status500(models::ErrorMessage),
57 UnknownValue(serde_json::Value),
58}
59
60#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum DisableServiceError {
64 Status401(models::ErrorMessage),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum DiscoverFeedError {
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum EnableFeedError {
79 Status401(models::ErrorMessage),
80 Status500(models::ErrorMessage),
81 UnknownValue(serde_json::Value),
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
86#[serde(untagged)]
87pub enum EnableServiceError {
88 Status401(models::ErrorMessage),
89 Status500(models::ErrorMessage),
90 UnknownValue(serde_json::Value),
91}
92
93#[derive(Debug, Clone, Serialize, Deserialize)]
95#[serde(untagged)]
96pub enum GetFeedError {
97 Status401(models::ErrorMessage),
98 Status404(models::ErrorMessage),
99 Status500(models::ErrorMessage),
100 UnknownValue(serde_json::Value),
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum GetProfileError {
107 Status401(models::ErrorMessage),
108 Status404(models::ErrorMessage),
109 Status500(models::ErrorMessage),
110 UnknownValue(serde_json::Value),
111}
112
113#[derive(Debug, Clone, Serialize, Deserialize)]
115#[serde(untagged)]
116pub enum GetStatsError {
117 Status401(models::ErrorMessage),
118 Status500(models::ErrorMessage),
119 UnknownValue(serde_json::Value),
120}
121
122#[derive(Debug, Clone, Serialize, Deserialize)]
124#[serde(untagged)]
125pub enum ListFeedError {
126 Status401(models::ErrorMessage),
127 Status500(models::ErrorMessage),
128 UnknownValue(serde_json::Value),
129}
130
131#[derive(Debug, Clone, Serialize, Deserialize)]
133#[serde(untagged)]
134pub enum PostProfileError {
135 Status401(models::ErrorMessage),
136 Status500(models::ErrorMessage),
137 UnknownValue(serde_json::Value),
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize)]
142#[serde(untagged)]
143pub enum UpdateFeedError {
144 Status401(models::ErrorMessage),
145 Status500(models::ErrorMessage),
146 UnknownValue(serde_json::Value),
147}
148
149
150pub async fn create_feed(configuration: &Configuration, feed_request: Option<models::FeedRequest>) -> Result<models::Feed, Error<CreateFeedError>> {
151 let p_body_feed_request = feed_request;
153
154 let uri_str = format!("{}/rss2email/feed", build_url(configuration));
155 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
156
157
158 if let Some(ref token) = configuration.oauth_access_token {
159 req_builder = req_builder.bearer_auth(token.to_owned());
160 };
161 if let Some(ref value) = configuration.api_key {
162 req_builder = req_builder.header("X-API-KEY", value);
163 };
164 req_builder = req_builder.json(&p_body_feed_request);
165
166 let req = req_builder.build()?;
167 let resp = configuration.client.execute(req).await?;
168
169 let status = resp.status();
170 let content_type = resp
171 .headers()
172 .get("content-type")
173 .and_then(|v| v.to_str().ok())
174 .unwrap_or("application/octet-stream");
175 let content_type = super::ContentType::from(content_type);
176
177 if !status.is_client_error() && !status.is_server_error() {
178 let content = resp.text().await?;
179 match content_type {
180 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
181 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Feed`"))),
182 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Feed`")))),
183 }
184 } else {
185 let content = resp.text().await?;
186 let entity: Option<CreateFeedError> = serde_json::from_str(&content).ok();
187 Err(Error::ResponseError(ResponseContent { status, content, entity }))
188 }
189}
190
191pub async fn delete_feed(configuration: &Configuration, feed_id: &str) -> Result<models::FeedResponse, Error<DeleteFeedError>> {
192 let p_path_feed_id = feed_id;
194
195 let uri_str = format!("{}/rss2email/feed/{feed_id}", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
196 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
197
198
199 if let Some(ref token) = configuration.oauth_access_token {
200 req_builder = req_builder.bearer_auth(token.to_owned());
201 };
202 if let Some(ref value) = configuration.api_key {
203 req_builder = req_builder.header("X-API-KEY", value);
204 };
205
206 let req = req_builder.build()?;
207 let resp = configuration.client.execute(req).await?;
208
209 let status = resp.status();
210 let content_type = resp
211 .headers()
212 .get("content-type")
213 .and_then(|v| v.to_str().ok())
214 .unwrap_or("application/octet-stream");
215 let content_type = super::ContentType::from(content_type);
216
217 if !status.is_client_error() && !status.is_server_error() {
218 let content = resp.text().await?;
219 match content_type {
220 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
221 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FeedResponse`"))),
222 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FeedResponse`")))),
223 }
224 } else {
225 let content = resp.text().await?;
226 let entity: Option<DeleteFeedError> = serde_json::from_str(&content).ok();
227 Err(Error::ResponseError(ResponseContent { status, content, entity }))
228 }
229}
230
231pub async fn disable_feed(configuration: &Configuration, feed_id: &str) -> Result<(), Error<DisableFeedError>> {
232 let p_path_feed_id = feed_id;
234
235 let uri_str = format!("{}/rss2email/feed/{feed_id}/disable", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
236 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
237
238
239 if let Some(ref token) = configuration.oauth_access_token {
240 req_builder = req_builder.bearer_auth(token.to_owned());
241 };
242 if let Some(ref value) = configuration.api_key {
243 req_builder = req_builder.header("X-API-KEY", value);
244 };
245
246 let req = req_builder.build()?;
247 let resp = configuration.client.execute(req).await?;
248
249 let status = resp.status();
250
251 if !status.is_client_error() && !status.is_server_error() {
252 Ok(())
253 } else {
254 let content = resp.text().await?;
255 let entity: Option<DisableFeedError> = serde_json::from_str(&content).ok();
256 Err(Error::ResponseError(ResponseContent { status, content, entity }))
257 }
258}
259
260pub async fn disable_service(configuration: &Configuration) -> Result<(), Error<DisableServiceError>> {
261
262 let uri_str = format!("{}/disable", build_url(configuration));
263 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
264
265
266 if let Some(ref token) = configuration.oauth_access_token {
267 req_builder = req_builder.bearer_auth(token.to_owned());
268 };
269 if let Some(ref value) = configuration.api_key {
270 req_builder = req_builder.header("X-API-KEY", value);
271 };
272
273 let req = req_builder.build()?;
274 let resp = configuration.client.execute(req).await?;
275
276 let status = resp.status();
277
278 if !status.is_client_error() && !status.is_server_error() {
279 Ok(())
280 } else {
281 let content = resp.text().await?;
282 let entity: Option<DisableServiceError> = serde_json::from_str(&content).ok();
283 Err(Error::ResponseError(ResponseContent { status, content, entity }))
284 }
285}
286
287pub async fn discover_feed(configuration: &Configuration, discover_feed_request: Option<models::DiscoverFeedRequest>) -> Result<models::DiscoverFeed200Response, Error<DiscoverFeedError>> {
288 let p_body_discover_feed_request = discover_feed_request;
290
291 let uri_str = format!("{}/rss2email/discover", build_url(configuration));
292 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
293
294
295 if let Some(ref token) = configuration.oauth_access_token {
296 req_builder = req_builder.bearer_auth(token.to_owned());
297 };
298 if let Some(ref value) = configuration.api_key {
299 req_builder = req_builder.header("X-API-KEY", value);
300 };
301 req_builder = req_builder.json(&p_body_discover_feed_request);
302
303 let req = req_builder.build()?;
304 let resp = configuration.client.execute(req).await?;
305
306 let status = resp.status();
307 let content_type = resp
308 .headers()
309 .get("content-type")
310 .and_then(|v| v.to_str().ok())
311 .unwrap_or("application/octet-stream");
312 let content_type = super::ContentType::from(content_type);
313
314 if !status.is_client_error() && !status.is_server_error() {
315 let content = resp.text().await?;
316 match content_type {
317 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
318 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DiscoverFeed200Response`"))),
319 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DiscoverFeed200Response`")))),
320 }
321 } else {
322 let content = resp.text().await?;
323 let entity: Option<DiscoverFeedError> = serde_json::from_str(&content).ok();
324 Err(Error::ResponseError(ResponseContent { status, content, entity }))
325 }
326}
327
328pub async fn enable_feed(configuration: &Configuration, feed_id: &str) -> Result<(), Error<EnableFeedError>> {
329 let p_path_feed_id = feed_id;
331
332 let uri_str = format!("{}/rss2email/feed/{feed_id}/enable", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
333 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
334
335
336 if let Some(ref token) = configuration.oauth_access_token {
337 req_builder = req_builder.bearer_auth(token.to_owned());
338 };
339 if let Some(ref value) = configuration.api_key {
340 req_builder = req_builder.header("X-API-KEY", value);
341 };
342
343 let req = req_builder.build()?;
344 let resp = configuration.client.execute(req).await?;
345
346 let status = resp.status();
347
348 if !status.is_client_error() && !status.is_server_error() {
349 Ok(())
350 } else {
351 let content = resp.text().await?;
352 let entity: Option<EnableFeedError> = serde_json::from_str(&content).ok();
353 Err(Error::ResponseError(ResponseContent { status, content, entity }))
354 }
355}
356
357pub async fn enable_service(configuration: &Configuration) -> Result<(), Error<EnableServiceError>> {
358
359 let uri_str = format!("{}/enable", build_url(configuration));
360 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
361
362
363 if let Some(ref token) = configuration.oauth_access_token {
364 req_builder = req_builder.bearer_auth(token.to_owned());
365 };
366 if let Some(ref value) = configuration.api_key {
367 req_builder = req_builder.header("X-API-KEY", value);
368 };
369
370 let req = req_builder.build()?;
371 let resp = configuration.client.execute(req).await?;
372
373 let status = resp.status();
374
375 if !status.is_client_error() && !status.is_server_error() {
376 Ok(())
377 } else {
378 let content = resp.text().await?;
379 let entity: Option<EnableServiceError> = serde_json::from_str(&content).ok();
380 Err(Error::ResponseError(ResponseContent { status, content, entity }))
381 }
382}
383
384pub async fn get_feed(configuration: &Configuration, feed_id: &str) -> Result<models::Feed, Error<GetFeedError>> {
385 let p_path_feed_id = feed_id;
387
388 let uri_str = format!("{}/rss2email/feed/{feed_id}", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
389 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
390
391
392 if let Some(ref token) = configuration.oauth_access_token {
393 req_builder = req_builder.bearer_auth(token.to_owned());
394 };
395 if let Some(ref value) = configuration.api_key {
396 req_builder = req_builder.header("X-API-KEY", value);
397 };
398
399 let req = req_builder.build()?;
400 let resp = configuration.client.execute(req).await?;
401
402 let status = resp.status();
403 let content_type = resp
404 .headers()
405 .get("content-type")
406 .and_then(|v| v.to_str().ok())
407 .unwrap_or("application/octet-stream");
408 let content_type = super::ContentType::from(content_type);
409
410 if !status.is_client_error() && !status.is_server_error() {
411 let content = resp.text().await?;
412 match content_type {
413 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
414 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Feed`"))),
415 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Feed`")))),
416 }
417 } else {
418 let content = resp.text().await?;
419 let entity: Option<GetFeedError> = serde_json::from_str(&content).ok();
420 Err(Error::ResponseError(ResponseContent { status, content, entity }))
421 }
422}
423
424pub async fn get_profile(configuration: &Configuration) -> Result<models::ProfileResponse, Error<GetProfileError>> {
425
426 let uri_str = format!("{}/rss2email/profile", build_url(configuration));
427 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
428
429
430 if let Some(ref token) = configuration.oauth_access_token {
431 req_builder = req_builder.bearer_auth(token.to_owned());
432 };
433 if let Some(ref value) = configuration.api_key {
434 req_builder = req_builder.header("X-API-KEY", value);
435 };
436
437 let req = req_builder.build()?;
438 let resp = configuration.client.execute(req).await?;
439
440 let status = resp.status();
441 let content_type = resp
442 .headers()
443 .get("content-type")
444 .and_then(|v| v.to_str().ok())
445 .unwrap_or("application/octet-stream");
446 let content_type = super::ContentType::from(content_type);
447
448 if !status.is_client_error() && !status.is_server_error() {
449 let content = resp.text().await?;
450 match content_type {
451 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
452 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProfileResponse`"))),
453 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ProfileResponse`")))),
454 }
455 } else {
456 let content = resp.text().await?;
457 let entity: Option<GetProfileError> = serde_json::from_str(&content).ok();
458 Err(Error::ResponseError(ResponseContent { status, content, entity }))
459 }
460}
461
462pub async fn get_stats(configuration: &Configuration) -> Result<models::FeedStatistics, Error<GetStatsError>> {
463
464 let uri_str = format!("{}/stats", build_url(configuration));
465 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
466
467
468 if let Some(ref token) = configuration.oauth_access_token {
469 req_builder = req_builder.bearer_auth(token.to_owned());
470 };
471 if let Some(ref value) = configuration.api_key {
472 req_builder = req_builder.header("X-API-KEY", value);
473 };
474
475 let req = req_builder.build()?;
476 let resp = configuration.client.execute(req).await?;
477
478 let status = resp.status();
479 let content_type = resp
480 .headers()
481 .get("content-type")
482 .and_then(|v| v.to_str().ok())
483 .unwrap_or("application/octet-stream");
484 let content_type = super::ContentType::from(content_type);
485
486 if !status.is_client_error() && !status.is_server_error() {
487 let content = resp.text().await?;
488 match content_type {
489 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
490 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FeedStatistics`"))),
491 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FeedStatistics`")))),
492 }
493 } else {
494 let content = resp.text().await?;
495 let entity: Option<GetStatsError> = serde_json::from_str(&content).ok();
496 Err(Error::ResponseError(ResponseContent { status, content, entity }))
497 }
498}
499
500pub async fn list_feed(configuration: &Configuration) -> Result<Vec<models::Feed>, Error<ListFeedError>> {
501
502 let uri_str = format!("{}/rss2email/feed", build_url(configuration));
503 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
504
505
506 if let Some(ref token) = configuration.oauth_access_token {
507 req_builder = req_builder.bearer_auth(token.to_owned());
508 };
509 if let Some(ref value) = configuration.api_key {
510 req_builder = req_builder.header("X-API-KEY", value);
511 };
512
513 let req = req_builder.build()?;
514 let resp = configuration.client.execute(req).await?;
515
516 let status = resp.status();
517 let content_type = resp
518 .headers()
519 .get("content-type")
520 .and_then(|v| v.to_str().ok())
521 .unwrap_or("application/octet-stream");
522 let content_type = super::ContentType::from(content_type);
523
524 if !status.is_client_error() && !status.is_server_error() {
525 let content = resp.text().await?;
526 match content_type {
527 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
528 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Feed>`"))),
529 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::Feed>`")))),
530 }
531 } else {
532 let content = resp.text().await?;
533 let entity: Option<ListFeedError> = serde_json::from_str(&content).ok();
534 Err(Error::ResponseError(ResponseContent { status, content, entity }))
535 }
536}
537
538pub async fn post_profile(configuration: &Configuration, profile: Option<models::Profile>) -> Result<(), Error<PostProfileError>> {
539 let p_body_profile = profile;
541
542 let uri_str = format!("{}/rss2email/profile", build_url(configuration));
543 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
544
545
546 if let Some(ref token) = configuration.oauth_access_token {
547 req_builder = req_builder.bearer_auth(token.to_owned());
548 };
549 if let Some(ref value) = configuration.api_key {
550 req_builder = req_builder.header("X-API-KEY", value);
551 };
552 req_builder = req_builder.json(&p_body_profile);
553
554 let req = req_builder.build()?;
555 let resp = configuration.client.execute(req).await?;
556
557 let status = resp.status();
558
559 if !status.is_client_error() && !status.is_server_error() {
560 Ok(())
561 } else {
562 let content = resp.text().await?;
563 let entity: Option<PostProfileError> = serde_json::from_str(&content).ok();
564 Err(Error::ResponseError(ResponseContent { status, content, entity }))
565 }
566}
567
568pub async fn update_feed(configuration: &Configuration, feed_id: &str, feed_request: Option<models::FeedRequest>) -> Result<models::FeedResponse, Error<UpdateFeedError>> {
569 let p_path_feed_id = feed_id;
571 let p_body_feed_request = feed_request;
572
573 let uri_str = format!("{}/rss2email/feed/{feed_id}", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
574 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
575
576
577 if let Some(ref token) = configuration.oauth_access_token {
578 req_builder = req_builder.bearer_auth(token.to_owned());
579 };
580 if let Some(ref value) = configuration.api_key {
581 req_builder = req_builder.header("X-API-KEY", value);
582 };
583 req_builder = req_builder.json(&p_body_feed_request);
584
585 let req = req_builder.build()?;
586 let resp = configuration.client.execute(req).await?;
587
588 let status = resp.status();
589 let content_type = resp
590 .headers()
591 .get("content-type")
592 .and_then(|v| v.to_str().ok())
593 .unwrap_or("application/octet-stream");
594 let content_type = super::ContentType::from(content_type);
595
596 if !status.is_client_error() && !status.is_server_error() {
597 let content = resp.text().await?;
598 match content_type {
599 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
600 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FeedResponse`"))),
601 ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FeedResponse`")))),
602 }
603 } else {
604 let content = resp.text().await?;
605 let entity: Option<UpdateFeedError> = serde_json::from_str(&content).ok();
606 Err(Error::ResponseError(ResponseContent { status, content, entity }))
607 }
608}
609