pub use reqwest_middleware::ClientWithMiddleware;
#[derive(Clone)]
#[non_exhaustive]
pub struct Configuration {
pub base_path: String,
pub user_agent: Option<String>,
pub client: reqwest_middleware::ClientWithMiddleware,
pub basic_auth: Option<BasicAuth>,
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
pub debug: bool,
}
pub type BasicAuth = (String, Option<String>);
#[derive(Clone)]
pub struct ApiKey {
pub prefix: Option<String>,
pub key: String,
}
impl std::fmt::Debug for ApiKey {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("ApiKey")
.field("prefix", &self.prefix)
.field("key", &"[REDACTED]")
.finish()
}
}
impl std::fmt::Debug for Configuration {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut debug = f.debug_struct("Configuration");
debug
.field("base_path", &self.base_path)
.field("user_agent", &self.user_agent)
.field("client", &self.client)
.field("debug", &self.debug);
debug
.field(
"basic_auth",
&self.basic_auth.as_ref().map(|(username, password)| {
(username, password.as_ref().map(|_| "[REDACTED]"))
}),
)
.field(
"oauth_access_token",
&self.oauth_access_token.as_ref().map(|_| "[REDACTED]"),
)
.field(
"bearer_access_token",
&self.bearer_access_token.as_ref().map(|_| "[REDACTED]"),
)
.field("api_key", &self.api_key);
debug.finish()
}
}
impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
}
}
impl Default for Configuration {
fn default() -> Self {
Configuration {
base_path: "https://api.vrchat.cloud/api/1".to_owned(),
user_agent: Some("vrchatapi-rust".to_owned()),
client: reqwest_middleware::ClientBuilder::new(
reqwest::Client::builder()
.cookie_store(true)
.build()
.unwrap(),
)
.build(),
basic_auth: None,
oauth_access_token: None,
bearer_access_token: None,
api_key: None,
debug: false,
}
}
}