#[derive(Debug, Clone)]
pub struct ApiConfig {
pub host: String,
pub timeout: u64,
pub api_key: Option<String>,
}
impl ApiConfig {
pub fn new(base_url: &str, network: &str, chain_id: &str) -> Self {
Self {
host: format!(
"{}/chainweb/0.0/{}/chain/{}/pact",
base_url, network, chain_id
),
timeout: 30,
api_key: None,
}
}
pub fn with_timeout(mut self, seconds: u64) -> Self {
self.timeout = seconds;
self
}
pub fn with_api_key(mut self, api_key: impl Into<String>) -> Self {
self.api_key = Some(api_key.into());
self
}
}