"""
Configuration for Crexperium SDK.
"""
from dataclasses import dataclass
from typing import Optional


@dataclass
class Config:
    """
    Configuration for CRM client.

    Args:
        api_token: API token for authentication
        base_url: Base URL of the CRM API (default: http://localhost:8000)
        timeout: Request timeout in seconds (default: 30)
        max_retries: Maximum number of retries for failed requests (default: 3)
        retry_delay: Initial delay between retries in seconds (default: 1)
        verify_ssl: Whether to verify SSL certificates (default: True)
    """

    api_token: str
    base_url: str = "http://localhost:8000"
    timeout: int = 30
    max_retries: int = 3
    retry_delay: float = 1.0
    verify_ssl: bool = True

    def __post_init__(self):
        """Validate configuration."""
        if not self.api_token:
            raise ValueError("api_token is required")

        # Remove trailing slash from base_url
        if self.base_url.endswith("/"):
            self.base_url = self.base_url[:-1]

        # Validate timeout
        if self.timeout <= 0:
            raise ValueError("timeout must be positive")

        # Validate max_retries
        if self.max_retries < 0:
            raise ValueError("max_retries must be non-negative")

        # Validate retry_delay
        if self.retry_delay < 0:
            raise ValueError("retry_delay must be non-negative")
