use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::healthcare::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum EligibilityCheckPostError {
UnknownValue(serde_json::Value),
}
pub async fn eligibility_check_post(configuration: &configuration::Configuration, x_forwarded_for: Option<&str>) -> Result<(), Error<EligibilityCheckPostError>> {
let p_header_x_forwarded_for = x_forwarded_for;
let uri_str = format!("{}/eligibility-check", configuration.base_path);
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_x_forwarded_for {
req_builder = req_builder.header("X-Forwarded-For", param_value.to_string());
}
if let Some(ref apikey) = configuration.api_key {
let key = apikey.key.clone();
let value = match apikey.prefix {
Some(ref prefix) => format!("{} {}", prefix, key),
None => key,
};
req_builder = req_builder.header("Authorization", value);
};
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<EligibilityCheckPostError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}