use crate::client::Vonage;
use vonage_core::{Result, Region, HttpConfig, Auth};
use std::time::Duration;
#[derive(Debug)]
pub struct VonageBuilder {
http_config: HttpConfig,
}
impl VonageBuilder {
pub fn new() -> Self {
Self {
http_config: HttpConfig::default(),
}
}
pub fn region(mut self, region: Region) -> Self {
self.http_config = self.http_config.with_region(region);
self
}
pub fn timeout(mut self, timeout: Duration) -> Self {
self.http_config = self.http_config.with_timeout(timeout);
self
}
pub fn user_agent(mut self, user_agent: impl Into<String>) -> Self {
self.http_config = self.http_config.with_user_agent(user_agent);
self
}
pub fn max_retries(mut self, max_retries: u32) -> Self {
self.http_config = self.http_config.with_max_retries(max_retries);
self
}
pub fn debug(mut self, debug: bool) -> Self {
self.http_config = self.http_config.with_debug(debug);
self
}
pub fn build<A: Auth + Clone + Send + Sync + 'static>(self, auth: A) -> Result<Vonage> {
Vonage::with_config(auth, self.http_config)
}
}
impl Default for VonageBuilder {
fn default() -> Self {
Self::new()
}
}