motis_openapi_sdk/apis/
debug_api.rs

1/*
2 * MOTIS API
3 *
4 * This is the MOTIS routing API.
5 *
6 * The version of the OpenAPI document: v1
7 * Contact: felix@triptix.tech
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration};
16
17
18/// struct for typed errors of method [`footpaths`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum FootpathsError {
22    UnknownValue(serde_json::Value),
23}
24
25
26pub async fn footpaths(configuration: &configuration::Configuration, id: &str) -> Result<models::Footpaths200Response, Error<FootpathsError>> {
27    let local_var_configuration = configuration;
28
29    let local_var_client = &local_var_configuration.client;
30
31    let local_var_uri_str = format!("{}/api/debug/footpaths", local_var_configuration.base_path);
32    let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
33
34    local_var_req_builder = local_var_req_builder.query(&[("id", &id.to_string())]);
35    if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
36        local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
37    }
38
39    let local_var_req = local_var_req_builder.build()?;
40    let local_var_resp = local_var_client.execute(local_var_req).await?;
41
42    let local_var_status = local_var_resp.status();
43    let local_var_content = local_var_resp.text().await?;
44
45    if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
46        serde_json::from_str(&local_var_content).map_err(Error::from)
47    } else {
48        let local_var_entity: Option<FootpathsError> = serde_json::from_str(&local_var_content).ok();
49        let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
50        Err(Error::ResponseError(local_var_error))
51    }
52}
53