use crate::steam::steam_client::configuration::steam_configuration::{
HttpClientPurpose, SteamConfiguration,
};
use super::web_api::{AsyncInterface, Interface};
pub trait SteamConfigurationWebApiExtensions {
fn get_web_api_interface(&self, iface: &str) -> Interface;
fn get_async_web_api_interface(&self, iface: &str) -> AsyncInterface;
}
impl SteamConfigurationWebApiExtensions for SteamConfiguration {
fn get_web_api_interface(&self, iface: &str) -> Interface {
Interface::new(
get_http_client_for_web_api(self),
self.web_api_base_address().clone(),
iface,
self.web_api_key(),
)
}
fn get_async_web_api_interface(&self, iface: &str) -> AsyncInterface {
AsyncInterface::new(
get_http_client_for_web_api(self),
self.web_api_base_address().clone(),
iface,
self.web_api_key(),
)
}
}
pub fn get_web_api_interface(config: &SteamConfiguration, iface: &str) -> Interface {
Interface::new(
get_http_client_for_web_api(config),
config.web_api_base_address().clone(),
iface,
config.web_api_key(),
)
}
pub fn get_async_web_api_interface(config: &SteamConfiguration, iface: &str) -> AsyncInterface {
AsyncInterface::new(
get_http_client_for_web_api(config),
config.web_api_base_address().clone(),
iface,
config.web_api_key(),
)
}
pub(crate) fn get_http_client_for_web_api(config: &SteamConfiguration) -> reqwest::Client {
let factory = config.http_client_factory();
factory(HttpClientPurpose::WebAPI)
}