Skip to main content

mobilitydata_client/apis/
feeds_api.rs

1/*
2 * Mobility Database Catalog
3 *
4 * API for the Mobility Database Catalog. See [https://mobilitydatabase.org/](https://mobilitydatabase.org/).  The Mobility Database API uses OAuth2 authentication. To initiate a successful API request, an access token must be included as a bearer token in the HTTP header. Access tokens are valid for one hour. To obtain an access token, you'll first need a refresh token, which is long-lived and does not expire. 
5 *
6 * The version of the OpenAPI document: 1.0.0
7 * Contact: api@mobilitydata.org
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`get_feed`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum GetFeedError {
22    UnknownValue(serde_json::Value),
23}
24
25/// struct for typed errors of method [`get_feeds`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum GetFeedsError {
29    UnknownValue(serde_json::Value),
30}
31
32/// struct for typed errors of method [`get_gbfs_feed`]
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(untagged)]
35pub enum GetGbfsFeedError {
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`get_gbfs_feeds`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum GetGbfsFeedsError {
43    UnknownValue(serde_json::Value),
44}
45
46/// struct for typed errors of method [`get_gtfs_feed`]
47#[derive(Debug, Clone, Serialize, Deserialize)]
48#[serde(untagged)]
49pub enum GetGtfsFeedError {
50    UnknownValue(serde_json::Value),
51}
52
53/// struct for typed errors of method [`get_gtfs_feed_datasets`]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[serde(untagged)]
56pub enum GetGtfsFeedDatasetsError {
57    UnknownValue(serde_json::Value),
58}
59
60/// struct for typed errors of method [`get_gtfs_feed_gtfs_rt_feeds`]
61#[derive(Debug, Clone, Serialize, Deserialize)]
62#[serde(untagged)]
63pub enum GetGtfsFeedGtfsRtFeedsError {
64    UnknownValue(serde_json::Value),
65}
66
67/// struct for typed errors of method [`get_gtfs_feeds`]
68#[derive(Debug, Clone, Serialize, Deserialize)]
69#[serde(untagged)]
70pub enum GetGtfsFeedsError {
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`get_gtfs_rt_feed`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum GetGtfsRtFeedError {
78    UnknownValue(serde_json::Value),
79}
80
81/// struct for typed errors of method [`get_gtfs_rt_feeds`]
82#[derive(Debug, Clone, Serialize, Deserialize)]
83#[serde(untagged)]
84pub enum GetGtfsRtFeedsError {
85    UnknownValue(serde_json::Value),
86}
87
88
89/// Get the specified feed from the Mobility Database.
90pub async fn get_feed(configuration: &configuration::Configuration, id: &str) -> Result<models::Feed, Error<GetFeedError>> {
91    // add a prefix to parameters to efficiently prevent name collisions
92    let p_path_id = id;
93
94    let uri_str = format!("{}/v1/feeds/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
95    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
96
97    if let Some(ref user_agent) = configuration.user_agent {
98        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
99    }
100    if let Some(ref token) = configuration.bearer_access_token {
101        req_builder = req_builder.bearer_auth(token.to_owned());
102    };
103
104    let req = req_builder.build()?;
105    let resp = configuration.client.execute(req).await?;
106
107    let status = resp.status();
108    let content_type = resp
109        .headers()
110        .get("content-type")
111        .and_then(|v| v.to_str().ok())
112        .unwrap_or("application/octet-stream");
113    let content_type = super::ContentType::from(content_type);
114
115    if !status.is_client_error() && !status.is_server_error() {
116        let content = resp.text().await?;
117        match content_type {
118            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
119            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Feed`"))),
120            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`")))),
121        }
122    } else {
123        let content = resp.text().await?;
124        let entity: Option<GetFeedError> = serde_json::from_str(&content).ok();
125        Err(Error::ResponseError(ResponseContent { status, content, entity }))
126    }
127}
128
129/// Get some (or all) feeds from the Mobility Database. The items are sorted by provider in alphabetical ascending order.
130pub async fn get_feeds(configuration: &configuration::Configuration, limit: Option<i32>, offset: Option<i32>, status: Option<&str>, provider: Option<&str>, producer_url: Option<&str>, is_official: Option<bool>) -> Result<Vec<models::Feed>, Error<GetFeedsError>> {
131    // add a prefix to parameters to efficiently prevent name collisions
132    let p_query_limit = limit;
133    let p_query_offset = offset;
134    let p_query_status = status;
135    let p_query_provider = provider;
136    let p_query_producer_url = producer_url;
137    let p_query_is_official = is_official;
138
139    let uri_str = format!("{}/v1/feeds", configuration.base_path);
140    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
141
142    if let Some(ref param_value) = p_query_limit {
143        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
144    }
145    if let Some(ref param_value) = p_query_offset {
146        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
147    }
148    if let Some(ref param_value) = p_query_status {
149        req_builder = req_builder.query(&[("status", &param_value.to_string())]);
150    }
151    if let Some(ref param_value) = p_query_provider {
152        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
153    }
154    if let Some(ref param_value) = p_query_producer_url {
155        req_builder = req_builder.query(&[("producer_url", &param_value.to_string())]);
156    }
157    if let Some(ref param_value) = p_query_is_official {
158        req_builder = req_builder.query(&[("is_official", &param_value.to_string())]);
159    }
160    if let Some(ref user_agent) = configuration.user_agent {
161        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
162    }
163    if let Some(ref token) = configuration.bearer_access_token {
164        req_builder = req_builder.bearer_auth(token.to_owned());
165    };
166
167    let req = req_builder.build()?;
168    let resp = configuration.client.execute(req).await?;
169
170    let status = resp.status();
171    let content_type = resp
172        .headers()
173        .get("content-type")
174        .and_then(|v| v.to_str().ok())
175        .unwrap_or("application/octet-stream");
176    let content_type = super::ContentType::from(content_type);
177
178    if !status.is_client_error() && !status.is_server_error() {
179        let content = resp.text().await?;
180        match content_type {
181            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
182            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Feed&gt;`"))),
183            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&lt;models::Feed&gt;`")))),
184        }
185    } else {
186        let content = resp.text().await?;
187        let entity: Option<GetFeedsError> = serde_json::from_str(&content).ok();
188        Err(Error::ResponseError(ResponseContent { status, content, entity }))
189    }
190}
191
192/// Get the specified GBFS feed from the Mobility Database.
193pub async fn get_gbfs_feed(configuration: &configuration::Configuration, id: &str) -> Result<models::GbfsFeed, Error<GetGbfsFeedError>> {
194    // add a prefix to parameters to efficiently prevent name collisions
195    let p_path_id = id;
196
197    let uri_str = format!("{}/v1/gbfs_feeds/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
198    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
199
200    if let Some(ref user_agent) = configuration.user_agent {
201        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
202    }
203    if let Some(ref token) = configuration.bearer_access_token {
204        req_builder = req_builder.bearer_auth(token.to_owned());
205    };
206
207    let req = req_builder.build()?;
208    let resp = configuration.client.execute(req).await?;
209
210    let status = resp.status();
211    let content_type = resp
212        .headers()
213        .get("content-type")
214        .and_then(|v| v.to_str().ok())
215        .unwrap_or("application/octet-stream");
216    let content_type = super::ContentType::from(content_type);
217
218    if !status.is_client_error() && !status.is_server_error() {
219        let content = resp.text().await?;
220        match content_type {
221            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
222            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GbfsFeed`"))),
223            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::GbfsFeed`")))),
224        }
225    } else {
226        let content = resp.text().await?;
227        let entity: Option<GetGbfsFeedError> = serde_json::from_str(&content).ok();
228        Err(Error::ResponseError(ResponseContent { status, content, entity }))
229    }
230}
231
232/// Get GBFS feeds from the Mobility Database.
233pub async fn get_gbfs_feeds(configuration: &configuration::Configuration, limit: Option<i32>, offset: Option<i32>, provider: Option<&str>, producer_url: Option<&str>, country_code: Option<&str>, subdivision_name: Option<&str>, municipality: Option<&str>, system_id: Option<&str>, version: Option<&str>) -> Result<Vec<models::GbfsFeed>, Error<GetGbfsFeedsError>> {
234    // add a prefix to parameters to efficiently prevent name collisions
235    let p_query_limit = limit;
236    let p_query_offset = offset;
237    let p_query_provider = provider;
238    let p_query_producer_url = producer_url;
239    let p_query_country_code = country_code;
240    let p_query_subdivision_name = subdivision_name;
241    let p_query_municipality = municipality;
242    let p_query_system_id = system_id;
243    let p_query_version = version;
244
245    let uri_str = format!("{}/v1/gbfs_feeds", configuration.base_path);
246    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
247
248    if let Some(ref param_value) = p_query_limit {
249        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
250    }
251    if let Some(ref param_value) = p_query_offset {
252        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
253    }
254    if let Some(ref param_value) = p_query_provider {
255        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
256    }
257    if let Some(ref param_value) = p_query_producer_url {
258        req_builder = req_builder.query(&[("producer_url", &param_value.to_string())]);
259    }
260    if let Some(ref param_value) = p_query_country_code {
261        req_builder = req_builder.query(&[("country_code", &param_value.to_string())]);
262    }
263    if let Some(ref param_value) = p_query_subdivision_name {
264        req_builder = req_builder.query(&[("subdivision_name", &param_value.to_string())]);
265    }
266    if let Some(ref param_value) = p_query_municipality {
267        req_builder = req_builder.query(&[("municipality", &param_value.to_string())]);
268    }
269    if let Some(ref param_value) = p_query_system_id {
270        req_builder = req_builder.query(&[("system_id", &param_value.to_string())]);
271    }
272    if let Some(ref param_value) = p_query_version {
273        req_builder = req_builder.query(&[("version", &param_value.to_string())]);
274    }
275    if let Some(ref user_agent) = configuration.user_agent {
276        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
277    }
278    if let Some(ref token) = configuration.bearer_access_token {
279        req_builder = req_builder.bearer_auth(token.to_owned());
280    };
281
282    let req = req_builder.build()?;
283    let resp = configuration.client.execute(req).await?;
284
285    let status = resp.status();
286    let content_type = resp
287        .headers()
288        .get("content-type")
289        .and_then(|v| v.to_str().ok())
290        .unwrap_or("application/octet-stream");
291    let content_type = super::ContentType::from(content_type);
292
293    if !status.is_client_error() && !status.is_server_error() {
294        let content = resp.text().await?;
295        match content_type {
296            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
297            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GbfsFeed&gt;`"))),
298            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&lt;models::GbfsFeed&gt;`")))),
299        }
300    } else {
301        let content = resp.text().await?;
302        let entity: Option<GetGbfsFeedsError> = serde_json::from_str(&content).ok();
303        Err(Error::ResponseError(ResponseContent { status, content, entity }))
304    }
305}
306
307/// Get the specified GTFS feed from the Mobility Database. Once a week, we check if the latest dataset has been updated and, if so, we update it in our system accordingly.
308pub async fn get_gtfs_feed(configuration: &configuration::Configuration, id: &str) -> Result<models::GtfsFeed, Error<GetGtfsFeedError>> {
309    // add a prefix to parameters to efficiently prevent name collisions
310    let p_path_id = id;
311
312    let uri_str = format!("{}/v1/gtfs_feeds/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
313    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
314
315    if let Some(ref user_agent) = configuration.user_agent {
316        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
317    }
318    if let Some(ref token) = configuration.bearer_access_token {
319        req_builder = req_builder.bearer_auth(token.to_owned());
320    };
321
322    let req = req_builder.build()?;
323    let resp = configuration.client.execute(req).await?;
324
325    let status = resp.status();
326    let content_type = resp
327        .headers()
328        .get("content-type")
329        .and_then(|v| v.to_str().ok())
330        .unwrap_or("application/octet-stream");
331    let content_type = super::ContentType::from(content_type);
332
333    if !status.is_client_error() && !status.is_server_error() {
334        let content = resp.text().await?;
335        match content_type {
336            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
337            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GtfsFeed`"))),
338            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::GtfsFeed`")))),
339        }
340    } else {
341        let content = resp.text().await?;
342        let entity: Option<GetGtfsFeedError> = serde_json::from_str(&content).ok();
343        Err(Error::ResponseError(ResponseContent { status, content, entity }))
344    }
345}
346
347/// Get a list of datasets associated with a GTFS feed. Once a day, we check whether the latest dataset has changed; if it has, we update it in our system. The list is sorted from newest to oldest.
348pub async fn get_gtfs_feed_datasets(configuration: &configuration::Configuration, id: &str, latest: Option<bool>, limit: Option<i32>, offset: Option<i32>, downloaded_after: Option<String>, downloaded_before: Option<String>) -> Result<Vec<models::GtfsDataset>, Error<GetGtfsFeedDatasetsError>> {
349    // add a prefix to parameters to efficiently prevent name collisions
350    let p_path_id = id;
351    let p_query_latest = latest;
352    let p_query_limit = limit;
353    let p_query_offset = offset;
354    let p_query_downloaded_after = downloaded_after;
355    let p_query_downloaded_before = downloaded_before;
356
357    let uri_str = format!("{}/v1/gtfs_feeds/{id}/datasets", configuration.base_path, id=crate::apis::urlencode(p_path_id));
358    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
359
360    if let Some(ref param_value) = p_query_latest {
361        req_builder = req_builder.query(&[("latest", &param_value.to_string())]);
362    }
363    if let Some(ref param_value) = p_query_limit {
364        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
365    }
366    if let Some(ref param_value) = p_query_offset {
367        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
368    }
369    if let Some(ref param_value) = p_query_downloaded_after {
370        req_builder = req_builder.query(&[("downloaded_after", &param_value.to_string())]);
371    }
372    if let Some(ref param_value) = p_query_downloaded_before {
373        req_builder = req_builder.query(&[("downloaded_before", &param_value.to_string())]);
374    }
375    if let Some(ref user_agent) = configuration.user_agent {
376        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
377    }
378    if let Some(ref token) = configuration.bearer_access_token {
379        req_builder = req_builder.bearer_auth(token.to_owned());
380    };
381
382    let req = req_builder.build()?;
383    let resp = configuration.client.execute(req).await?;
384
385    let status = resp.status();
386    let content_type = resp
387        .headers()
388        .get("content-type")
389        .and_then(|v| v.to_str().ok())
390        .unwrap_or("application/octet-stream");
391    let content_type = super::ContentType::from(content_type);
392
393    if !status.is_client_error() && !status.is_server_error() {
394        let content = resp.text().await?;
395        match content_type {
396            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
397            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GtfsDataset&gt;`"))),
398            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&lt;models::GtfsDataset&gt;`")))),
399        }
400    } else {
401        let content = resp.text().await?;
402        let entity: Option<GetGtfsFeedDatasetsError> = serde_json::from_str(&content).ok();
403        Err(Error::ResponseError(ResponseContent { status, content, entity }))
404    }
405}
406
407/// Get a list of GTFS Realtime related to a GTFS feed.
408pub async fn get_gtfs_feed_gtfs_rt_feeds(configuration: &configuration::Configuration, id: &str) -> Result<Vec<models::GtfsRtFeed>, Error<GetGtfsFeedGtfsRtFeedsError>> {
409    // add a prefix to parameters to efficiently prevent name collisions
410    let p_path_id = id;
411
412    let uri_str = format!("{}/v1/gtfs_feeds/{id}/gtfs_rt_feeds", configuration.base_path, id=crate::apis::urlencode(p_path_id));
413    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
414
415    if let Some(ref user_agent) = configuration.user_agent {
416        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
417    }
418    if let Some(ref token) = configuration.bearer_access_token {
419        req_builder = req_builder.bearer_auth(token.to_owned());
420    };
421
422    let req = req_builder.build()?;
423    let resp = configuration.client.execute(req).await?;
424
425    let status = resp.status();
426    let content_type = resp
427        .headers()
428        .get("content-type")
429        .and_then(|v| v.to_str().ok())
430        .unwrap_or("application/octet-stream");
431    let content_type = super::ContentType::from(content_type);
432
433    if !status.is_client_error() && !status.is_server_error() {
434        let content = resp.text().await?;
435        match content_type {
436            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
437            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GtfsRtFeed&gt;`"))),
438            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&lt;models::GtfsRtFeed&gt;`")))),
439        }
440    } else {
441        let content = resp.text().await?;
442        let entity: Option<GetGtfsFeedGtfsRtFeedsError> = serde_json::from_str(&content).ok();
443        Err(Error::ResponseError(ResponseContent { status, content, entity }))
444    }
445}
446
447/// Get some (or all) GTFS feeds from the Mobility Database.
448pub async fn get_gtfs_feeds(configuration: &configuration::Configuration, limit: Option<i32>, offset: Option<i32>, provider: Option<&str>, producer_url: Option<&str>, country_code: Option<&str>, subdivision_name: Option<&str>, municipality: Option<&str>, dataset_latitudes: Option<&str>, dataset_longitudes: Option<&str>, bounding_filter_method: Option<&str>, is_official: Option<bool>) -> Result<Vec<models::GtfsFeed>, Error<GetGtfsFeedsError>> {
449    // add a prefix to parameters to efficiently prevent name collisions
450    let p_query_limit = limit;
451    let p_query_offset = offset;
452    let p_query_provider = provider;
453    let p_query_producer_url = producer_url;
454    let p_query_country_code = country_code;
455    let p_query_subdivision_name = subdivision_name;
456    let p_query_municipality = municipality;
457    let p_query_dataset_latitudes = dataset_latitudes;
458    let p_query_dataset_longitudes = dataset_longitudes;
459    let p_query_bounding_filter_method = bounding_filter_method;
460    let p_query_is_official = is_official;
461
462    let uri_str = format!("{}/v1/gtfs_feeds", configuration.base_path);
463    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
464
465    if let Some(ref param_value) = p_query_limit {
466        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
467    }
468    if let Some(ref param_value) = p_query_offset {
469        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
470    }
471    if let Some(ref param_value) = p_query_provider {
472        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
473    }
474    if let Some(ref param_value) = p_query_producer_url {
475        req_builder = req_builder.query(&[("producer_url", &param_value.to_string())]);
476    }
477    if let Some(ref param_value) = p_query_country_code {
478        req_builder = req_builder.query(&[("country_code", &param_value.to_string())]);
479    }
480    if let Some(ref param_value) = p_query_subdivision_name {
481        req_builder = req_builder.query(&[("subdivision_name", &param_value.to_string())]);
482    }
483    if let Some(ref param_value) = p_query_municipality {
484        req_builder = req_builder.query(&[("municipality", &param_value.to_string())]);
485    }
486    if let Some(ref param_value) = p_query_dataset_latitudes {
487        req_builder = req_builder.query(&[("dataset_latitudes", &param_value.to_string())]);
488    }
489    if let Some(ref param_value) = p_query_dataset_longitudes {
490        req_builder = req_builder.query(&[("dataset_longitudes", &param_value.to_string())]);
491    }
492    if let Some(ref param_value) = p_query_bounding_filter_method {
493        req_builder = req_builder.query(&[("bounding_filter_method", &param_value.to_string())]);
494    }
495    if let Some(ref param_value) = p_query_is_official {
496        req_builder = req_builder.query(&[("is_official", &param_value.to_string())]);
497    }
498    if let Some(ref user_agent) = configuration.user_agent {
499        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
500    }
501    if let Some(ref token) = configuration.bearer_access_token {
502        req_builder = req_builder.bearer_auth(token.to_owned());
503    };
504
505    let req = req_builder.build()?;
506    let resp = configuration.client.execute(req).await?;
507
508    let status = resp.status();
509    let content_type = resp
510        .headers()
511        .get("content-type")
512        .and_then(|v| v.to_str().ok())
513        .unwrap_or("application/octet-stream");
514    let content_type = super::ContentType::from(content_type);
515
516    if !status.is_client_error() && !status.is_server_error() {
517        let content = resp.text().await?;
518        match content_type {
519            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
520            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GtfsFeed&gt;`"))),
521            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&lt;models::GtfsFeed&gt;`")))),
522        }
523    } else {
524        let content = resp.text().await?;
525        let entity: Option<GetGtfsFeedsError> = serde_json::from_str(&content).ok();
526        Err(Error::ResponseError(ResponseContent { status, content, entity }))
527    }
528}
529
530/// Get the specified GTFS Realtime feed from the Mobility Database.
531pub async fn get_gtfs_rt_feed(configuration: &configuration::Configuration, id: &str) -> Result<models::GtfsRtFeed, Error<GetGtfsRtFeedError>> {
532    // add a prefix to parameters to efficiently prevent name collisions
533    let p_path_id = id;
534
535    let uri_str = format!("{}/v1/gtfs_rt_feeds/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
536    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
537
538    if let Some(ref user_agent) = configuration.user_agent {
539        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
540    }
541    if let Some(ref token) = configuration.bearer_access_token {
542        req_builder = req_builder.bearer_auth(token.to_owned());
543    };
544
545    let req = req_builder.build()?;
546    let resp = configuration.client.execute(req).await?;
547
548    let status = resp.status();
549    let content_type = resp
550        .headers()
551        .get("content-type")
552        .and_then(|v| v.to_str().ok())
553        .unwrap_or("application/octet-stream");
554    let content_type = super::ContentType::from(content_type);
555
556    if !status.is_client_error() && !status.is_server_error() {
557        let content = resp.text().await?;
558        match content_type {
559            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
560            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GtfsRtFeed`"))),
561            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::GtfsRtFeed`")))),
562        }
563    } else {
564        let content = resp.text().await?;
565        let entity: Option<GetGtfsRtFeedError> = serde_json::from_str(&content).ok();
566        Err(Error::ResponseError(ResponseContent { status, content, entity }))
567    }
568}
569
570/// Get some (or all) GTFS Realtime feeds from the Mobility Database.
571pub async fn get_gtfs_rt_feeds(configuration: &configuration::Configuration, limit: Option<i32>, offset: Option<i32>, provider: Option<&str>, producer_url: Option<&str>, entity_types: Option<&str>, country_code: Option<&str>, subdivision_name: Option<&str>, municipality: Option<&str>, is_official: Option<bool>) -> Result<Vec<models::GtfsRtFeed>, Error<GetGtfsRtFeedsError>> {
572    // add a prefix to parameters to efficiently prevent name collisions
573    let p_query_limit = limit;
574    let p_query_offset = offset;
575    let p_query_provider = provider;
576    let p_query_producer_url = producer_url;
577    let p_query_entity_types = entity_types;
578    let p_query_country_code = country_code;
579    let p_query_subdivision_name = subdivision_name;
580    let p_query_municipality = municipality;
581    let p_query_is_official = is_official;
582
583    let uri_str = format!("{}/v1/gtfs_rt_feeds", configuration.base_path);
584    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
585
586    if let Some(ref param_value) = p_query_limit {
587        req_builder = req_builder.query(&[("limit", &param_value.to_string())]);
588    }
589    if let Some(ref param_value) = p_query_offset {
590        req_builder = req_builder.query(&[("offset", &param_value.to_string())]);
591    }
592    if let Some(ref param_value) = p_query_provider {
593        req_builder = req_builder.query(&[("provider", &param_value.to_string())]);
594    }
595    if let Some(ref param_value) = p_query_producer_url {
596        req_builder = req_builder.query(&[("producer_url", &param_value.to_string())]);
597    }
598    if let Some(ref param_value) = p_query_entity_types {
599        req_builder = req_builder.query(&[("entity_types", &param_value.to_string())]);
600    }
601    if let Some(ref param_value) = p_query_country_code {
602        req_builder = req_builder.query(&[("country_code", &param_value.to_string())]);
603    }
604    if let Some(ref param_value) = p_query_subdivision_name {
605        req_builder = req_builder.query(&[("subdivision_name", &param_value.to_string())]);
606    }
607    if let Some(ref param_value) = p_query_municipality {
608        req_builder = req_builder.query(&[("municipality", &param_value.to_string())]);
609    }
610    if let Some(ref param_value) = p_query_is_official {
611        req_builder = req_builder.query(&[("is_official", &param_value.to_string())]);
612    }
613    if let Some(ref user_agent) = configuration.user_agent {
614        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
615    }
616    if let Some(ref token) = configuration.bearer_access_token {
617        req_builder = req_builder.bearer_auth(token.to_owned());
618    };
619
620    let req = req_builder.build()?;
621    let resp = configuration.client.execute(req).await?;
622
623    let status = resp.status();
624    let content_type = resp
625        .headers()
626        .get("content-type")
627        .and_then(|v| v.to_str().ok())
628        .unwrap_or("application/octet-stream");
629    let content_type = super::ContentType::from(content_type);
630
631    if !status.is_client_error() && !status.is_server_error() {
632        let content = resp.text().await?;
633        match content_type {
634            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
635            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::GtfsRtFeed&gt;`"))),
636            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&lt;models::GtfsRtFeed&gt;`")))),
637        }
638    } else {
639        let content = resp.text().await?;
640        let entity: Option<GetGtfsRtFeedsError> = serde_json::from_str(&content).ok();
641        Err(Error::ResponseError(ResponseContent { status, content, entity }))
642    }
643}
644