vonage 0.1.1

Unified Rust SDK for Vonage APIs
Documentation
//! Vonage client builder for configuration

use crate::client::Vonage;
use vonage_core::{Result, Region, HttpConfig, Auth};
use std::time::Duration;

/// Builder for creating a configured Vonage client
#[derive(Debug)]
pub struct VonageBuilder {
    http_config: HttpConfig,
}

impl VonageBuilder {
    /// Create a new builder with default configuration
    pub fn new() -> Self {
        Self {
            http_config: HttpConfig::default(),
        }
    }
    
    /// Set the API region
    pub fn region(mut self, region: Region) -> Self {
        self.http_config = self.http_config.with_region(region);
        self
    }
    
    /// Set the request timeout
    pub fn timeout(mut self, timeout: Duration) -> Self {
        self.http_config = self.http_config.with_timeout(timeout);
        self
    }
    
    /// Set the user agent string
    pub fn user_agent(mut self, user_agent: impl Into<String>) -> Self {
        self.http_config = self.http_config.with_user_agent(user_agent);
        self
    }
    
    /// Set the maximum number of retries for failed requests
    pub fn max_retries(mut self, max_retries: u32) -> Self {
        self.http_config = self.http_config.with_max_retries(max_retries);
        self
    }
    
    /// Enable or disable debug logging of HTTP requests and responses
    pub fn debug(mut self, debug: bool) -> Self {
        self.http_config = self.http_config.with_debug(debug);
        self
    }
    
    /// Build the Vonage client with the provided authentication
    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()
    }
}