1use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum AddFeedError {
22 Status403(models::UnauthorizedApiError),
23 Status404(models::NotFoundApiError),
24 DefaultResponse(models::ApiError),
25 UnknownValue(serde_json::Value),
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CacheFeedsError {
32 Status403(models::UnauthorizedApiError),
33 Status404(models::NotFoundApiError),
34 DefaultResponse(models::ApiError),
35 UnknownValue(serde_json::Value),
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum DisableFeedError {
42 Status403(models::UnauthorizedApiError),
43 Status404(models::NotFoundApiError),
44 DefaultResponse(models::ApiError),
45 UnknownValue(serde_json::Value),
46}
47
48#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(untagged)]
51pub enum EditFeedError {
52 Status403(models::UnauthorizedApiError),
53 Status404(models::NotFoundApiError),
54 DefaultResponse(models::ApiError),
55 UnknownValue(serde_json::Value),
56}
57
58#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum EnableFeedError {
62 Status403(models::UnauthorizedApiError),
63 Status404(models::NotFoundApiError),
64 DefaultResponse(models::ApiError),
65 UnknownValue(serde_json::Value),
66}
67
68#[derive(Debug, Clone, Serialize, Deserialize)]
70#[serde(untagged)]
71pub enum FetchFromAllFeedsError {
72 Status403(models::UnauthorizedApiError),
73 Status404(models::NotFoundApiError),
74 DefaultResponse(models::ApiError),
75 UnknownValue(serde_json::Value),
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize)]
80#[serde(untagged)]
81pub enum FetchFromFeedError {
82 Status403(models::UnauthorizedApiError),
83 Status404(models::NotFoundApiError),
84 DefaultResponse(models::ApiError),
85 UnknownValue(serde_json::Value),
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(untagged)]
91pub enum GetFeedByIdError {
92 Status403(models::UnauthorizedApiError),
93 Status404(models::NotFoundApiError),
94 DefaultResponse(models::ApiError),
95 UnknownValue(serde_json::Value),
96}
97
98#[derive(Debug, Clone, Serialize, Deserialize)]
100#[serde(untagged)]
101pub enum GetFeedsError {
102 Status403(models::UnauthorizedApiError),
103 Status404(models::NotFoundApiError),
104 DefaultResponse(models::ApiError),
105 UnknownValue(serde_json::Value),
106}
107
108
109pub async fn add_feed(configuration: &configuration::Configuration, add_feed_request: Option<models::AddFeedRequest>) -> Result<models::GetFeeds200ResponseInner, Error<AddFeedError>> {
110 let p_add_feed_request = add_feed_request;
112
113 let uri_str = format!("{}/feeds/add", configuration.base_path);
114 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
115
116 if let Some(ref user_agent) = configuration.user_agent {
117 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
118 }
119 if let Some(ref apikey) = configuration.api_key {
120 let key = apikey.key.clone();
121 let value = match apikey.prefix {
122 Some(ref prefix) => format!("{} {}", prefix, key),
123 None => key,
124 };
125 req_builder = req_builder.header("Authorization", value);
126 };
127 req_builder = req_builder.json(&p_add_feed_request);
128
129 let req = req_builder.build()?;
130 let resp = configuration.client.execute(req).await?;
131
132 let status = resp.status();
133 let content_type = resp
134 .headers()
135 .get("content-type")
136 .and_then(|v| v.to_str().ok())
137 .unwrap_or("application/octet-stream");
138 let content_type = super::ContentType::from(content_type);
139
140 if !status.is_client_error() && !status.is_server_error() {
141 let content = resp.text().await?;
142 match content_type {
143 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
144 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetFeeds200ResponseInner`"))),
145 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::GetFeeds200ResponseInner`")))),
146 }
147 } else {
148 let content = resp.text().await?;
149 let entity: Option<AddFeedError> = serde_json::from_str(&content).ok();
150 Err(Error::ResponseError(ResponseContent { status, content, entity }))
151 }
152}
153
154pub async fn cache_feeds(configuration: &configuration::Configuration, cache_feeds_scope: &str) -> Result<models::CacheFeeds200Response, Error<CacheFeedsError>> {
155 let p_cache_feeds_scope = cache_feeds_scope;
157
158 let uri_str = format!("{}/feeds/cacheFeeds/{cacheFeedsScope}", configuration.base_path, cacheFeedsScope=crate::apis::urlencode(p_cache_feeds_scope));
159 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
160
161 if let Some(ref user_agent) = configuration.user_agent {
162 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
163 }
164 if let Some(ref apikey) = configuration.api_key {
165 let key = apikey.key.clone();
166 let value = match apikey.prefix {
167 Some(ref prefix) => format!("{} {}", prefix, key),
168 None => key,
169 };
170 req_builder = req_builder.header("Authorization", value);
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 => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CacheFeeds200Response`"))),
189 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::CacheFeeds200Response`")))),
190 }
191 } else {
192 let content = resp.text().await?;
193 let entity: Option<CacheFeedsError> = serde_json::from_str(&content).ok();
194 Err(Error::ResponseError(ResponseContent { status, content, entity }))
195 }
196}
197
198pub async fn disable_feed(configuration: &configuration::Configuration, feed_id: &str) -> Result<models::DisableFeed200Response, Error<DisableFeedError>> {
199 let p_feed_id = feed_id;
201
202 let uri_str = format!("{}/feeds/disable/{feedId}", configuration.base_path, feedId=p_feed_id.to_string());
203 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
204
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 apikey) = configuration.api_key {
209 let key = apikey.key.clone();
210 let value = match apikey.prefix {
211 Some(ref prefix) => format!("{} {}", prefix, key),
212 None => key,
213 };
214 req_builder = req_builder.header("Authorization", value);
215 };
216
217 let req = req_builder.build()?;
218 let resp = configuration.client.execute(req).await?;
219
220 let status = resp.status();
221 let content_type = resp
222 .headers()
223 .get("content-type")
224 .and_then(|v| v.to_str().ok())
225 .unwrap_or("application/octet-stream");
226 let content_type = super::ContentType::from(content_type);
227
228 if !status.is_client_error() && !status.is_server_error() {
229 let content = resp.text().await?;
230 match content_type {
231 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
232 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DisableFeed200Response`"))),
233 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::DisableFeed200Response`")))),
234 }
235 } else {
236 let content = resp.text().await?;
237 let entity: Option<DisableFeedError> = serde_json::from_str(&content).ok();
238 Err(Error::ResponseError(ResponseContent { status, content, entity }))
239 }
240}
241
242pub async fn edit_feed(configuration: &configuration::Configuration, feed_id: &str, edit_feed_request: Option<models::EditFeedRequest>) -> Result<models::GetFeeds200ResponseInner, Error<EditFeedError>> {
243 let p_feed_id = feed_id;
245 let p_edit_feed_request = edit_feed_request;
246
247 let uri_str = format!("{}/feeds/edit/{feedId}", configuration.base_path, feedId=p_feed_id.to_string());
248 let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
249
250 if let Some(ref user_agent) = configuration.user_agent {
251 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
252 }
253 if let Some(ref apikey) = configuration.api_key {
254 let key = apikey.key.clone();
255 let value = match apikey.prefix {
256 Some(ref prefix) => format!("{} {}", prefix, key),
257 None => key,
258 };
259 req_builder = req_builder.header("Authorization", value);
260 };
261 req_builder = req_builder.json(&p_edit_feed_request);
262
263 let req = req_builder.build()?;
264 let resp = configuration.client.execute(req).await?;
265
266 let status = resp.status();
267 let content_type = resp
268 .headers()
269 .get("content-type")
270 .and_then(|v| v.to_str().ok())
271 .unwrap_or("application/octet-stream");
272 let content_type = super::ContentType::from(content_type);
273
274 if !status.is_client_error() && !status.is_server_error() {
275 let content = resp.text().await?;
276 match content_type {
277 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
278 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetFeeds200ResponseInner`"))),
279 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::GetFeeds200ResponseInner`")))),
280 }
281 } else {
282 let content = resp.text().await?;
283 let entity: Option<EditFeedError> = serde_json::from_str(&content).ok();
284 Err(Error::ResponseError(ResponseContent { status, content, entity }))
285 }
286}
287
288pub async fn enable_feed(configuration: &configuration::Configuration, feed_id: &str) -> Result<models::EnableFeed200Response, Error<EnableFeedError>> {
289 let p_feed_id = feed_id;
291
292 let uri_str = format!("{}/feeds/enable/{feedId}", configuration.base_path, feedId=p_feed_id.to_string());
293 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
294
295 if let Some(ref user_agent) = configuration.user_agent {
296 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
297 }
298 if let Some(ref apikey) = configuration.api_key {
299 let key = apikey.key.clone();
300 let value = match apikey.prefix {
301 Some(ref prefix) => format!("{} {}", prefix, key),
302 None => key,
303 };
304 req_builder = req_builder.header("Authorization", value);
305 };
306
307 let req = req_builder.build()?;
308 let resp = configuration.client.execute(req).await?;
309
310 let status = resp.status();
311 let content_type = resp
312 .headers()
313 .get("content-type")
314 .and_then(|v| v.to_str().ok())
315 .unwrap_or("application/octet-stream");
316 let content_type = super::ContentType::from(content_type);
317
318 if !status.is_client_error() && !status.is_server_error() {
319 let content = resp.text().await?;
320 match content_type {
321 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
322 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::EnableFeed200Response`"))),
323 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::EnableFeed200Response`")))),
324 }
325 } else {
326 let content = resp.text().await?;
327 let entity: Option<EnableFeedError> = serde_json::from_str(&content).ok();
328 Err(Error::ResponseError(ResponseContent { status, content, entity }))
329 }
330}
331
332pub async fn fetch_from_all_feeds(configuration: &configuration::Configuration, ) -> Result<models::FetchFromFeed200Response, Error<FetchFromAllFeedsError>> {
333
334 let uri_str = format!("{}/feeds/fetchFromAllFeeds", configuration.base_path);
335 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
336
337 if let Some(ref user_agent) = configuration.user_agent {
338 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
339 }
340 if let Some(ref apikey) = configuration.api_key {
341 let key = apikey.key.clone();
342 let value = match apikey.prefix {
343 Some(ref prefix) => format!("{} {}", prefix, key),
344 None => key,
345 };
346 req_builder = req_builder.header("Authorization", value);
347 };
348
349 let req = req_builder.build()?;
350 let resp = configuration.client.execute(req).await?;
351
352 let status = resp.status();
353 let content_type = resp
354 .headers()
355 .get("content-type")
356 .and_then(|v| v.to_str().ok())
357 .unwrap_or("application/octet-stream");
358 let content_type = super::ContentType::from(content_type);
359
360 if !status.is_client_error() && !status.is_server_error() {
361 let content = resp.text().await?;
362 match content_type {
363 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
364 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FetchFromFeed200Response`"))),
365 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::FetchFromFeed200Response`")))),
366 }
367 } else {
368 let content = resp.text().await?;
369 let entity: Option<FetchFromAllFeedsError> = serde_json::from_str(&content).ok();
370 Err(Error::ResponseError(ResponseContent { status, content, entity }))
371 }
372}
373
374pub async fn fetch_from_feed(configuration: &configuration::Configuration, feed_id: &str) -> Result<models::FetchFromFeed200Response, Error<FetchFromFeedError>> {
375 let p_feed_id = feed_id;
377
378 let uri_str = format!("{}/feeds/fetchFromFeed/{feedId}", configuration.base_path, feedId=p_feed_id.to_string());
379 let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
380
381 if let Some(ref user_agent) = configuration.user_agent {
382 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
383 }
384 if let Some(ref apikey) = configuration.api_key {
385 let key = apikey.key.clone();
386 let value = match apikey.prefix {
387 Some(ref prefix) => format!("{} {}", prefix, key),
388 None => key,
389 };
390 req_builder = req_builder.header("Authorization", value);
391 };
392
393 let req = req_builder.build()?;
394 let resp = configuration.client.execute(req).await?;
395
396 let status = resp.status();
397 let content_type = resp
398 .headers()
399 .get("content-type")
400 .and_then(|v| v.to_str().ok())
401 .unwrap_or("application/octet-stream");
402 let content_type = super::ContentType::from(content_type);
403
404 if !status.is_client_error() && !status.is_server_error() {
405 let content = resp.text().await?;
406 match content_type {
407 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
408 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FetchFromFeed200Response`"))),
409 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::FetchFromFeed200Response`")))),
410 }
411 } else {
412 let content = resp.text().await?;
413 let entity: Option<FetchFromFeedError> = serde_json::from_str(&content).ok();
414 Err(Error::ResponseError(ResponseContent { status, content, entity }))
415 }
416}
417
418pub async fn get_feed_by_id(configuration: &configuration::Configuration, feed_id: &str) -> Result<models::GetFeeds200ResponseInner, Error<GetFeedByIdError>> {
419 let p_feed_id = feed_id;
421
422 let uri_str = format!("{}/feeds/view/{feedId}", configuration.base_path, feedId=p_feed_id.to_string());
423 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
424
425 if let Some(ref user_agent) = configuration.user_agent {
426 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
427 }
428 if let Some(ref apikey) = configuration.api_key {
429 let key = apikey.key.clone();
430 let value = match apikey.prefix {
431 Some(ref prefix) => format!("{} {}", prefix, key),
432 None => key,
433 };
434 req_builder = req_builder.header("Authorization", 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::GetFeeds200ResponseInner`"))),
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::GetFeeds200ResponseInner`")))),
454 }
455 } else {
456 let content = resp.text().await?;
457 let entity: Option<GetFeedByIdError> = serde_json::from_str(&content).ok();
458 Err(Error::ResponseError(ResponseContent { status, content, entity }))
459 }
460}
461
462pub async fn get_feeds(configuration: &configuration::Configuration, ) -> Result<Vec<models::GetFeeds200ResponseInner>, Error<GetFeedsError>> {
463
464 let uri_str = format!("{}/feeds", configuration.base_path);
465 let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
466
467 if let Some(ref user_agent) = configuration.user_agent {
468 req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
469 }
470 if let Some(ref apikey) = configuration.api_key {
471 let key = apikey.key.clone();
472 let value = match apikey.prefix {
473 Some(ref prefix) => format!("{} {}", prefix, key),
474 None => key,
475 };
476 req_builder = req_builder.header("Authorization", value);
477 };
478
479 let req = req_builder.build()?;
480 let resp = configuration.client.execute(req).await?;
481
482 let status = resp.status();
483 let content_type = resp
484 .headers()
485 .get("content-type")
486 .and_then(|v| v.to_str().ok())
487 .unwrap_or("application/octet-stream");
488 let content_type = super::ContentType::from(content_type);
489
490 if !status.is_client_error() && !status.is_server_error() {
491 let content = resp.text().await?;
492 match content_type {
493 ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
494 ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::GetFeeds200ResponseInner>`"))),
495 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::GetFeeds200ResponseInner>`")))),
496 }
497 } else {
498 let content = resp.text().await?;
499 let entity: Option<GetFeedsError> = serde_json::from_str(&content).ok();
500 Err(Error::ResponseError(ResponseContent { status, content, entity }))
501 }
502}
503