from __future__ import annotations

from .http import HttpClient
from .modules import OtpModule, AlertsModule, TicketsModule, BroadcastsModule


class AchekConnect:
    """
    Achek Connect Python SDK client.

    Args:
        api_key: Your Achek Connect API key (starts with ``watp_``)
        base_url: Override the API base URL (default: https://verify.achek.com.ng)
        timeout: Request timeout in seconds (default: 15)

    Example::

        from achekconnect import AchekConnect

        client = AchekConnect(api_key="watp_live_xxxxxxxxxxxx")

        # Send OTP
        result = client.otp.send("+2348XXXXXXXXX")
        request_id = result["requestId"]

        # Verify OTP
        if client.otp.verify(request_id, user_code)["valid"]:
            login_user()
    """

    def __init__(
        self,
        api_key: str,
        *,
        base_url: str = "https://api.achek.com.ng",
        timeout: int = 15,
    ):
        if not api_key:
            raise ValueError("api_key is required")
        http = HttpClient(api_key=api_key, base_url=base_url, timeout=timeout)
        self.otp = OtpModule(http)
        self.alerts = AlertsModule(http)
        self.tickets = TicketsModule(http)
        self.broadcasts = BroadcastsModule(http)
