pub struct WakapiClient {
api_url: String,
api_key: String,
}
impl WakapiClient {
pub fn new(api_url: &str, api_key: &str) -> Self {
Self {
api_url: api_url.to_string(),
api_key: api_key.to_string(),
}
}
pub fn build_url(&self, endpoint: &str, url_params: Option<String>) -> String {
let mut url = self.api_url.clone() + endpoint;
url = url.replace("/:user/", "/current/");
if let Some(params) = url_params {
url = url + "?" + ¶ms;
}
url
}
pub fn get_auth_header(&self) -> String {
format!("Basic {}", self.api_key)
}
}