#[derive(Clone)]
pub struct ApiServerConfig {
pub url: String,
pub port: u16,
pub use_test_env: bool,
}
impl ApiServerConfig {
pub const fn new(url: String, port: u16, use_test_env: bool) -> Self {
Self {
url,
port,
use_test_env,
}
}
pub fn remote(use_test_env: bool) -> Self {
Self {
url: "https://api.telegram.org".to_string(),
port: 443,
use_test_env,
}
}
pub fn local(url: Option<String>, port: Option<u16>, use_test_env: bool) -> Self {
Self {
url: url.unwrap_or_else(|| "http://localhost".to_string()),
port: port.unwrap_or(80),
use_test_env,
}
}
}
impl Default for ApiServerConfig {
fn default() -> Self {
Self::remote(false)
}
}