Skip to main content

highlevel_api/
config.rs

1#[derive(Debug, Clone)]
2pub struct HighLevelConfig {
3    pub client_id: String,
4    pub client_secret: String,
5    /// API version header sent with every request (e.g. "2021-07-28")
6    pub api_version: String,
7    pub base_url: String,
8    pub redirect_uri: Option<String>,
9}
10
11impl Default for HighLevelConfig {
12    fn default() -> Self {
13        Self {
14            client_id: String::new(),
15            client_secret: String::new(),
16            api_version: "2021-07-28".to_string(),
17            base_url: "https://services.leadconnectorhq.com".to_string(),
18            redirect_uri: None,
19        }
20    }
21}
22
23impl HighLevelConfig {
24    pub fn new(client_id: impl Into<String>, client_secret: impl Into<String>) -> Self {
25        Self {
26            client_id: client_id.into(),
27            client_secret: client_secret.into(),
28            ..Default::default()
29        }
30    }
31
32    pub fn with_redirect_uri(mut self, redirect_uri: impl Into<String>) -> Self {
33        self.redirect_uri = Some(redirect_uri.into());
34        self
35    }
36
37    pub fn with_api_version(mut self, version: impl Into<String>) -> Self {
38        self.api_version = version.into();
39        self
40    }
41}