use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCoachDeckLayoutError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCoachDeckLayoutsError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCoachLayoutsError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCoachLayoutsLayoutIdError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPassengerCategoriesError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPlacesError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProductTagsError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProductsError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetProductsIdError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetReductionCardsError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetZonesError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status415(models::Problem),
Status500(models::Problem),
Status501(models::Problem),
Status503(models::Problem),
DefaultResponse(models::Problem),
UnknownValue(serde_json::Value),
}
pub async fn get_coach_deck_layout(configuration: &configuration::Configuration, layout_id: &str, requestor: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::CoachDeckLayoutResponse, Error<GetCoachDeckLayoutError>> {
let p_path_layout_id = layout_id;
let p_header_requestor = requestor;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/coach-deck-layouts/{layoutId}", configuration.base_path, layoutId=crate::apis::urlencode(p_path_layout_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoachDeckLayoutResponse`"))),
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::CoachDeckLayoutResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCoachDeckLayoutError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_coach_deck_layouts(configuration: &configuration::Configuration, requestor: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, if_none_match: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::CoachDeckLayoutCollectionResponse, Error<GetCoachDeckLayoutsError>> {
let p_header_requestor = requestor;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_if_none_match = if_none_match;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/coach-deck-layouts", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoachDeckLayoutCollectionResponse`"))),
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::CoachDeckLayoutCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCoachDeckLayoutsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
#[deprecated]
pub async fn get_coach_layouts(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>, page: Option<&str>) -> Result<models::CoachLayoutCollectionResponse, Error<GetCoachLayoutsError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let p_query_page = page;
let uri_str = format!("{}/coach-layouts", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoachLayoutCollectionResponse`"))),
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::CoachLayoutCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCoachLayoutsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
#[deprecated]
pub async fn get_coach_layouts_layout_id(configuration: &configuration::Configuration, layout_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::CoachLayoutResponse, Error<GetCoachLayoutsLayoutIdError>> {
let p_path_layout_id = layout_id;
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/coach-layouts/{layoutId}", configuration.base_path, layoutId=crate::apis::urlencode(p_path_layout_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CoachLayoutResponse`"))),
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::CoachLayoutResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCoachLayoutsLayoutIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_passenger_categories(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>) -> Result<Vec<models::PassengerCategory>, Error<GetPassengerCategoriesError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let uri_str = format!("{}/passenger-categories", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::PassengerCategory>`"))),
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::PassengerCategory>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPassengerCategoriesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_places(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, if_none_match: Option<&str>, x_accept_namespace: Option<&str>, page: Option<&str>) -> Result<models::PlaceResponse, Error<GetPlacesError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_if_none_match = if_none_match;
let p_header_x_accept_namespace = x_accept_namespace;
let p_query_page = page;
let uri_str = format!("{}/places", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_if_none_match {
req_builder = req_builder.header("If-None-Match", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::PlaceResponse`"))),
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::PlaceResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPlacesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_product_tags(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::ProductTagsResponse, Error<GetProductTagsError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/product-tags", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProductTagsResponse`"))),
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::ProductTagsResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProductTagsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_products(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>, page: Option<&str>, product_code: Option<&str>, issuing_date: Option<String>, travel_date: Option<String>) -> Result<models::ProductCollectionResponse, Error<GetProductsError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let p_query_page = page;
let p_query_product_code = product_code;
let p_query_issuing_date = issuing_date;
let p_query_travel_date = travel_date;
let uri_str = format!("{}/products", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_product_code {
req_builder = req_builder.query(&[("productCode", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_issuing_date {
req_builder = req_builder.query(&[("issuingDate", ¶m_value.to_string())]);
}
if let Some(ref param_value) = p_query_travel_date {
req_builder = req_builder.query(&[("travelDate", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProductCollectionResponse`"))),
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::ProductCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProductsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_products_id(configuration: &configuration::Configuration, product_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::ProductResponse, Error<GetProductsIdError>> {
let p_path_product_id = product_id;
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/products/{productId}", configuration.base_path, productId=crate::apis::urlencode(p_path_product_id));
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ProductResponse`"))),
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::ProductResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetProductsIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_reduction_cards(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>, page: Option<&str>) -> Result<models::ReductionCardCollectionResponse, Error<GetReductionCardsError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let p_query_page = page;
let uri_str = format!("{}/reduction-cards", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ReductionCardCollectionResponse`"))),
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::ReductionCardCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetReductionCardsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_zones(configuration: &configuration::Configuration, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>, page: Option<&str>) -> Result<models::ZoneCollectionResponse, Error<GetZonesError>> {
let p_header_requestor = requestor;
let p_header_accept_language = accept_language;
let p_header_traceparent = traceparent;
let p_header_tracestate = tracestate;
let p_header_x_accept_namespace = x_accept_namespace;
let p_query_page = page;
let uri_str = format!("{}/zones", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
if let Some(ref param_value) = p_query_page {
req_builder = req_builder.query(&[("page", ¶m_value.to_string())]);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
if let Some(param_value) = p_header_requestor {
req_builder = req_builder.header("Requestor", param_value.to_string());
}
if let Some(param_value) = p_header_accept_language {
req_builder = req_builder.header("Accept-Language", param_value.to_string());
}
if let Some(param_value) = p_header_traceparent {
req_builder = req_builder.header("traceparent", param_value.to_string());
}
if let Some(param_value) = p_header_tracestate {
req_builder = req_builder.header("tracestate", param_value.to_string());
}
if let Some(param_value) = p_header_x_accept_namespace {
req_builder = req_builder.header("x-accept-namespace", param_value.to_string());
}
if let Some(ref token) = configuration.oauth_access_token {
req_builder = req_builder.bearer_auth(token.to_owned());
};
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ZoneCollectionResponse`"))),
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::ZoneCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetZonesError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}