wakapi 0.3.1

Wakatime API client
Documentation
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(),
        }
    }

    /// Build the full URL for the given endpoint, replacing /:user/ with "/current/" (for now).
    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 + "?" + &params;
        }
        url
    }

    /// Get Authorization header value for the client.
    pub fn get_auth_header(&self) -> String {
        format!("Basic {}", self.api_key)
    }
}