Skip to main content

motis_openapi_sdk/apis/
debug_api.rs

1/*
2 * MOTIS API
3 *
4 * This is the MOTIS routing API.  Overview of MOTIS API versions:  MOTIS 0.x - deprecated/discontinued  MOTIS 2.x - current, providing:  * /api/v5/{plan,trip,stoptimes,map/trips} renamed METRO mode to SUBURBAN, AREAL_LIFT to AERIAL_LIFT; since MOTIS 2.5.0 * /api/v4/{plan,trip,stoptimes,map/trips} new displayName property, routeShortName only contains actual route short name from source; since MOTIS 2.2.0 * /api/v3/plan with correct maxTransfers API parameter (transfers actually corresponding to number of changes between transit legs (and not to number of transit legs), i.e. maxTransfers=0 returns direct public transit connections, as expected); since MOTIS 2.0.84  * /api/v2/{plan,trip} returns Google polylines with precision=6; since MOTIS 2.0.60 * /api/v1/{plan,trip} returns Google polylines with precision=7 (not defined for |longitude|>107) * /api/v1/_* all other endpoints  If you use the JS client lib https://www.npmjs.com/package/@motis-project/motis-client, endpoint versions will be taken into account automatically (i.e. the newest one available will be used). 
5 *
6 * The version of the OpenAPI document: v5
7 * Contact: felix@triptix.tech
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 [`transfers`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum TransfersError {
22    UnknownValue(serde_json::Value),
23}
24
25
26pub async fn transfers(configuration: &configuration::Configuration, id: &str) -> Result<models::Transfers200Response, Error<TransfersError>> {
27    // add a prefix to parameters to efficiently prevent name collisions
28    let p_query_id = id;
29
30    let uri_str = format!("{}/api/debug/transfers", configuration.base_path);
31    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
32
33    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
34    if let Some(ref user_agent) = configuration.user_agent {
35        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
36    }
37
38    let req = req_builder.build()?;
39    let resp = configuration.client.execute(req).await?;
40
41    let status = resp.status();
42    let content_type = resp
43        .headers()
44        .get("content-type")
45        .and_then(|v| v.to_str().ok())
46        .unwrap_or("application/octet-stream");
47    let content_type = super::ContentType::from(content_type);
48
49    if !status.is_client_error() && !status.is_server_error() {
50        let content = resp.text().await?;
51        match content_type {
52            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
53            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Transfers200Response`"))),
54            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::Transfers200Response`")))),
55        }
56    } else {
57        let content = resp.text().await?;
58        let entity: Option<TransfersError> = serde_json::from_str(&content).ok();
59        Err(Error::ResponseError(ResponseContent { status, content, entity }))
60    }
61}
62