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 UnknownValue(serde_json::Value),
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(untagged)]
43pub enum DeleteFeedError {
44 UnknownValue(serde_json::Value),
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum DisableFeedError {
51 UnknownValue(serde_json::Value),
52}
53
54#[derive(Debug, Clone, Serialize, Deserialize)]
56#[serde(untagged)]
57pub enum DiscoverFeedError {
58 UnknownValue(serde_json::Value),
59}
60
61#[derive(Debug, Clone, Serialize, Deserialize)]
63#[serde(untagged)]
64pub enum EnableFeedError {
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum EnableServiceError {
72 UnknownValue(serde_json::Value),
73}
74
75#[derive(Debug, Clone, Serialize, Deserialize)]
77#[serde(untagged)]
78pub enum GetFeedError {
79 UnknownValue(serde_json::Value),
80}
81
82#[derive(Debug, Clone, Serialize, Deserialize)]
84#[serde(untagged)]
85pub enum GetProfileError {
86 UnknownValue(serde_json::Value),
87}
88
89#[derive(Debug, Clone, Serialize, Deserialize)]
91#[serde(untagged)]
92pub enum GetStatsError {
93 UnknownValue(serde_json::Value),
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
98#[serde(untagged)]
99pub enum ListFeedError {
100 UnknownValue(serde_json::Value),
101}
102
103#[derive(Debug, Clone, Serialize, Deserialize)]
105#[serde(untagged)]
106pub enum PostProfileError {
107 UnknownValue(serde_json::Value),
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum UpdateFeedError {
114 UnknownValue(serde_json::Value),
115}
116
117
118pub async fn create_feed(configuration: &Configuration, feed_request: Option<models::FeedRequest>) -> Result<models::Feed, Error<CreateFeedError>> {
119 let p_body_feed_request = feed_request;
121
122 let uri_str = format!("{}/rss2email/feed", build_url(configuration));
123 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
124
125
126 if let Some(ref token) = configuration.oauth_access_token {
127 req_builder = req_builder.bearer_auth(token.to_owned());
128 };
129 if let Some(ref value) = configuration.api_key {
130 req_builder = req_builder.header("X-API-KEY", value);
131 };
132 req_builder = req_builder.json(&p_body_feed_request);
133
134 let req = req_builder.build()?;
135 let resp = configuration.client.execute(req).await?;
136
137 let status = resp.status();
138 let content_type = resp
139 .headers()
140 .get("content-type")
141 .and_then(|v| v.to_str().ok())
142 .unwrap_or("application/octet-stream");
143 let content_type = super::ContentType::from(content_type);
144
145 if !status.is_client_error() && !status.is_server_error() {
146 let content = resp.text().await?;
147 match content_type {
148 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
149 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Feed`"))),
150 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`")))),
151 }
152 } else {
153 let content = resp.text().await?;
154 let entity: Option<CreateFeedError> = serde_json::from_str(&content).ok();
155 Err(Error::ResponseError(ResponseContent { status, content, entity }))
156 }
157}
158
159pub async fn delete_feed(configuration: &Configuration, feed_id: &str) -> Result<(), Error<DeleteFeedError>> {
160 let p_path_feed_id = feed_id;
162
163 let uri_str = format!("{}/rss2email/feed/{feed_id}", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
164 let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
165
166
167 if let Some(ref token) = configuration.oauth_access_token {
168 req_builder = req_builder.bearer_auth(token.to_owned());
169 };
170 if let Some(ref value) = configuration.api_key {
171 req_builder = req_builder.header("X-API-KEY", value);
172 };
173
174 let req = req_builder.build()?;
175 let resp = configuration.client.execute(req).await?;
176
177 let status = resp.status();
178
179 if !status.is_client_error() && !status.is_server_error() {
180 Ok(())
181 } else {
182 let content = resp.text().await?;
183 let entity: Option<DeleteFeedError> = serde_json::from_str(&content).ok();
184 Err(Error::ResponseError(ResponseContent { status, content, entity }))
185 }
186}
187
188pub async fn disable_feed(configuration: &Configuration, feed_id: &str) -> Result<(), Error<DisableFeedError>> {
189 let p_path_feed_id = feed_id;
191
192 let uri_str = format!("{}/rss2email/feed/{feed_id}/disable", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
193 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
194
195
196 if let Some(ref token) = configuration.oauth_access_token {
197 req_builder = req_builder.bearer_auth(token.to_owned());
198 };
199 if let Some(ref value) = configuration.api_key {
200 req_builder = req_builder.header("X-API-KEY", value);
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<DisableFeedError> = serde_json::from_str(&content).ok();
213 Err(Error::ResponseError(ResponseContent { status, content, entity }))
214 }
215}
216
217pub async fn discover_feed(configuration: &Configuration, discover_feed_request: Option<models::DiscoverFeedRequest>) -> Result<models::DiscoverFeed200Response, Error<DiscoverFeedError>> {
218 let p_body_discover_feed_request = discover_feed_request;
220
221 let uri_str = format!("{}/rss2email/discover", build_url(configuration));
222 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
223
224
225 if let Some(ref token) = configuration.oauth_access_token {
226 req_builder = req_builder.bearer_auth(token.to_owned());
227 };
228 if let Some(ref value) = configuration.api_key {
229 req_builder = req_builder.header("X-API-KEY", value);
230 };
231 req_builder = req_builder.json(&p_body_discover_feed_request);
232
233 let req = req_builder.build()?;
234 let resp = configuration.client.execute(req).await?;
235
236 let status = resp.status();
237 let content_type = resp
238 .headers()
239 .get("content-type")
240 .and_then(|v| v.to_str().ok())
241 .unwrap_or("application/octet-stream");
242 let content_type = super::ContentType::from(content_type);
243
244 if !status.is_client_error() && !status.is_server_error() {
245 let content = resp.text().await?;
246 match content_type {
247 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
248 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DiscoverFeed200Response`"))),
249 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`")))),
250 }
251 } else {
252 let content = resp.text().await?;
253 let entity: Option<DiscoverFeedError> = serde_json::from_str(&content).ok();
254 Err(Error::ResponseError(ResponseContent { status, content, entity }))
255 }
256}
257
258pub async fn enable_feed(configuration: &Configuration, feed_id: &str) -> Result<(), Error<EnableFeedError>> {
259 let p_path_feed_id = feed_id;
261
262 let uri_str = format!("{}/rss2email/feed/{feed_id}/enable", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
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<EnableFeedError> = serde_json::from_str(&content).ok();
283 Err(Error::ResponseError(ResponseContent { status, content, entity }))
284 }
285}
286
287pub async fn enable_service(configuration: &Configuration) -> Result<(), Error<EnableServiceError>> {
288
289 let uri_str = format!("{}/enable", build_url(configuration));
290 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
291
292
293 if let Some(ref token) = configuration.oauth_access_token {
294 req_builder = req_builder.bearer_auth(token.to_owned());
295 };
296 if let Some(ref value) = configuration.api_key {
297 req_builder = req_builder.header("X-API-KEY", value);
298 };
299
300 let req = req_builder.build()?;
301 let resp = configuration.client.execute(req).await?;
302
303 let status = resp.status();
304
305 if !status.is_client_error() && !status.is_server_error() {
306 Ok(())
307 } else {
308 let content = resp.text().await?;
309 let entity: Option<EnableServiceError> = serde_json::from_str(&content).ok();
310 Err(Error::ResponseError(ResponseContent { status, content, entity }))
311 }
312}
313
314pub async fn get_feed(configuration: &Configuration, feed_id: &str) -> Result<models::Feed, Error<GetFeedError>> {
315 let p_path_feed_id = feed_id;
317
318 let uri_str = format!("{}/rss2email/feed/{feed_id}", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
319 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
320
321
322 if let Some(ref token) = configuration.oauth_access_token {
323 req_builder = req_builder.bearer_auth(token.to_owned());
324 };
325 if let Some(ref value) = configuration.api_key {
326 req_builder = req_builder.header("X-API-KEY", value);
327 };
328
329 let req = req_builder.build()?;
330 let resp = configuration.client.execute(req).await?;
331
332 let status = resp.status();
333 let content_type = resp
334 .headers()
335 .get("content-type")
336 .and_then(|v| v.to_str().ok())
337 .unwrap_or("application/octet-stream");
338 let content_type = super::ContentType::from(content_type);
339
340 if !status.is_client_error() && !status.is_server_error() {
341 let content = resp.text().await?;
342 match content_type {
343 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
344 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Feed`"))),
345 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`")))),
346 }
347 } else {
348 let content = resp.text().await?;
349 let entity: Option<GetFeedError> = serde_json::from_str(&content).ok();
350 Err(Error::ResponseError(ResponseContent { status, content, entity }))
351 }
352}
353
354pub async fn get_profile(configuration: &Configuration) -> Result<models::Profile, Error<GetProfileError>> {
355
356 let uri_str = format!("{}/rss2email/profile", build_url(configuration));
357 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
358
359
360 if let Some(ref token) = configuration.oauth_access_token {
361 req_builder = req_builder.bearer_auth(token.to_owned());
362 };
363 if let Some(ref value) = configuration.api_key {
364 req_builder = req_builder.header("X-API-KEY", value);
365 };
366
367 let req = req_builder.build()?;
368 let resp = configuration.client.execute(req).await?;
369
370 let status = resp.status();
371 let content_type = resp
372 .headers()
373 .get("content-type")
374 .and_then(|v| v.to_str().ok())
375 .unwrap_or("application/octet-stream");
376 let content_type = super::ContentType::from(content_type);
377
378 if !status.is_client_error() && !status.is_server_error() {
379 let content = resp.text().await?;
380 match content_type {
381 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
382 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Profile`"))),
383 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::Profile`")))),
384 }
385 } else {
386 let content = resp.text().await?;
387 let entity: Option<GetProfileError> = serde_json::from_str(&content).ok();
388 Err(Error::ResponseError(ResponseContent { status, content, entity }))
389 }
390}
391
392pub async fn get_stats(configuration: &Configuration) -> Result<models::FeedStatistics, Error<GetStatsError>> {
393
394 let uri_str = format!("{}/stats", build_url(configuration));
395 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
396
397
398 if let Some(ref token) = configuration.oauth_access_token {
399 req_builder = req_builder.bearer_auth(token.to_owned());
400 };
401 if let Some(ref value) = configuration.api_key {
402 req_builder = req_builder.header("X-API-KEY", value);
403 };
404
405 let req = req_builder.build()?;
406 let resp = configuration.client.execute(req).await?;
407
408 let status = resp.status();
409 let content_type = resp
410 .headers()
411 .get("content-type")
412 .and_then(|v| v.to_str().ok())
413 .unwrap_or("application/octet-stream");
414 let content_type = super::ContentType::from(content_type);
415
416 if !status.is_client_error() && !status.is_server_error() {
417 let content = resp.text().await?;
418 match content_type {
419 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
420 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FeedStatistics`"))),
421 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`")))),
422 }
423 } else {
424 let content = resp.text().await?;
425 let entity: Option<GetStatsError> = serde_json::from_str(&content).ok();
426 Err(Error::ResponseError(ResponseContent { status, content, entity }))
427 }
428}
429
430pub async fn list_feed(configuration: &Configuration) -> Result<Vec<models::Feed>, Error<ListFeedError>> {
431
432 let uri_str = format!("{}/rss2email/feed", build_url(configuration));
433 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
434
435
436 if let Some(ref token) = configuration.oauth_access_token {
437 req_builder = req_builder.bearer_auth(token.to_owned());
438 };
439 if let Some(ref value) = configuration.api_key {
440 req_builder = req_builder.header("X-API-KEY", value);
441 };
442
443 let req = req_builder.build()?;
444 let resp = configuration.client.execute(req).await?;
445
446 let status = resp.status();
447 let content_type = resp
448 .headers()
449 .get("content-type")
450 .and_then(|v| v.to_str().ok())
451 .unwrap_or("application/octet-stream");
452 let content_type = super::ContentType::from(content_type);
453
454 if !status.is_client_error() && !status.is_server_error() {
455 let content = resp.text().await?;
456 match content_type {
457 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
458 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::Feed>`"))),
459 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>`")))),
460 }
461 } else {
462 let content = resp.text().await?;
463 let entity: Option<ListFeedError> = serde_json::from_str(&content).ok();
464 Err(Error::ResponseError(ResponseContent { status, content, entity }))
465 }
466}
467
468pub async fn post_profile(configuration: &Configuration, profile: Option<models::Profile>) -> Result<(), Error<PostProfileError>> {
469 let p_body_profile = profile;
471
472 let uri_str = format!("{}/rss2email/profile", build_url(configuration));
473 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
474
475
476 if let Some(ref token) = configuration.oauth_access_token {
477 req_builder = req_builder.bearer_auth(token.to_owned());
478 };
479 if let Some(ref value) = configuration.api_key {
480 req_builder = req_builder.header("X-API-KEY", value);
481 };
482 req_builder = req_builder.json(&p_body_profile);
483
484 let req = req_builder.build()?;
485 let resp = configuration.client.execute(req).await?;
486
487 let status = resp.status();
488
489 if !status.is_client_error() && !status.is_server_error() {
490 Ok(())
491 } else {
492 let content = resp.text().await?;
493 let entity: Option<PostProfileError> = serde_json::from_str(&content).ok();
494 Err(Error::ResponseError(ResponseContent { status, content, entity }))
495 }
496}
497
498pub async fn update_feed(configuration: &Configuration, feed_id: &str, feed_request: Option<models::FeedRequest>) -> Result<(), Error<UpdateFeedError>> {
499 let p_path_feed_id = feed_id;
501 let p_body_feed_request = feed_request;
502
503 let uri_str = format!("{}/rss2email/feed/{feed_id}", build_url(configuration), feed_id=crate::apis::urlencode(p_path_feed_id));
504 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
505
506
507 if let Some(ref token) = configuration.oauth_access_token {
508 req_builder = req_builder.bearer_auth(token.to_owned());
509 };
510 if let Some(ref value) = configuration.api_key {
511 req_builder = req_builder.header("X-API-KEY", value);
512 };
513 req_builder = req_builder.json(&p_body_feed_request);
514
515 let req = req_builder.build()?;
516 let resp = configuration.client.execute(req).await?;
517
518 let status = resp.status();
519
520 if !status.is_client_error() && !status.is_server_error() {
521 Ok(())
522 } else {
523 let content = resp.text().await?;
524 let entity: Option<UpdateFeedError> = serde_json::from_str(&content).ok();
525 Err(Error::ResponseError(ResponseContent { status, content, entity }))
526 }
527}
528