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 FinalizeFulfillmentsError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status409(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 GetCheckFulfillmentsError {
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 GetContinuousServiceUsageIdError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(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 GetFulfillmentIdError {
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 PatchContinuousServiceUsageIdError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status409(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 PatchFulfillmentIdError {
Status400(models::Problem),
Status401(models::Problem),
Status403(models::Problem),
Status404(models::Problem),
Status406(models::Problem),
Status409(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 PostFulfillmentsError {
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 finalize_fulfillments(configuration: &configuration::Configuration, booking_id: &str, fulfillment_patch_request: models::FulfillmentPatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentCollectionResponse, Error<FinalizeFulfillmentsError>> {
let p_path_booking_id = booking_id;
let p_body_fulfillment_patch_request = fulfillment_patch_request;
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_idempotency_key = idempotency_key;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/bookings/{bookingId}/fulfillments", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", 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());
};
req_builder = req_builder.json(&p_body_fulfillment_patch_request);
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::FulfillmentCollectionResponse`"))),
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::FulfillmentCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<FinalizeFulfillmentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_check_fulfillments(configuration: &configuration::Configuration, booking_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<(), Error<GetCheckFulfillmentsError>> {
let p_path_booking_id = booking_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_idempotency_key = idempotency_key;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/bookings/{bookingId}/fulfillment-check", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_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_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", 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();
if !status.is_client_error() && !status.is_server_error() {
Ok(())
} else {
let content = resp.text().await?;
let entity: Option<GetCheckFulfillmentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_continuous_service_usage_id(configuration: &configuration::Configuration, fulfillment_id: &str, continuous_service_usage_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::ContinuousServiceUsage, Error<GetContinuousServiceUsageIdError>> {
let p_path_fulfillment_id = fulfillment_id;
let p_path_continuous_service_usage_id = continuous_service_usage_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!("{}/fulfillments/{fulfillmentId}/continuous-service-usage/{continuousServiceUsageId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id), continuousServiceUsageId=crate::apis::urlencode(p_path_continuous_service_usage_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::ContinuousServiceUsage`"))),
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::ContinuousServiceUsage`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetContinuousServiceUsageIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_fulfillment_id(configuration: &configuration::Configuration, fulfillment_id: &str, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentResponse, Error<GetFulfillmentIdError>> {
let p_path_fulfillment_id = fulfillment_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!("{}/fulfillments/{fulfillmentId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_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::FulfillmentResponse`"))),
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::FulfillmentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetFulfillmentIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn patch_continuous_service_usage_id(configuration: &configuration::Configuration, fulfillment_id: &str, continuous_service_usage_id: &str, continuous_service_usage_patch_request: models::ContinuousServiceUsagePatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::ContinuousServiceUsage, Error<PatchContinuousServiceUsageIdError>> {
let p_path_fulfillment_id = fulfillment_id;
let p_path_continuous_service_usage_id = continuous_service_usage_id;
let p_body_continuous_service_usage_patch_request = continuous_service_usage_patch_request;
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_idempotency_key = idempotency_key;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/fulfillments/{fulfillmentId}/continuous-service-usage/{continuousServiceUsageId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id), continuousServiceUsageId=crate::apis::urlencode(p_path_continuous_service_usage_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", 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());
};
req_builder = req_builder.json(&p_body_continuous_service_usage_patch_request);
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::ContinuousServiceUsage`"))),
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::ContinuousServiceUsage`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchContinuousServiceUsageIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn patch_fulfillment_id(configuration: &configuration::Configuration, fulfillment_id: &str, fulfillment_activation_patch_request: models::FulfillmentActivationPatchRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentResponse, Error<PatchFulfillmentIdError>> {
let p_path_fulfillment_id = fulfillment_id;
let p_body_fulfillment_activation_patch_request = fulfillment_activation_patch_request;
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_idempotency_key = idempotency_key;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/fulfillments/{fulfillmentId}", configuration.base_path, fulfillmentId=crate::apis::urlencode(p_path_fulfillment_id));
let mut req_builder = configuration.client.request(reqwest::Method::PATCH, &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_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", 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());
};
req_builder = req_builder.json(&p_body_fulfillment_activation_patch_request);
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::FulfillmentResponse`"))),
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::FulfillmentResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PatchFulfillmentIdError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn post_fulfillments(configuration: &configuration::Configuration, booking_id: &str, fulfillment_post_request: models::FulfillmentPostRequest, requestor: Option<&str>, accept_language: Option<&str>, traceparent: Option<&str>, tracestate: Option<&str>, idempotency_key: Option<&str>, x_accept_namespace: Option<&str>) -> Result<models::FulfillmentCollectionResponse, Error<PostFulfillmentsError>> {
let p_path_booking_id = booking_id;
let p_body_fulfillment_post_request = fulfillment_post_request;
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_idempotency_key = idempotency_key;
let p_header_x_accept_namespace = x_accept_namespace;
let uri_str = format!("{}/bookings/{bookingId}/fulfillments", configuration.base_path, bookingId=crate::apis::urlencode(p_path_booking_id));
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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_idempotency_key {
req_builder = req_builder.header("Idempotency-Key", 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());
};
req_builder = req_builder.json(&p_body_fulfillment_post_request);
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::FulfillmentCollectionResponse`"))),
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::FulfillmentCollectionResponse`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<PostFulfillmentsError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}