from dataclasses import dataclass, field
from typing import Any, Protocol


class SmsProviderError(Exception):
    def __init__(self, message: str, *, status_code: int = 500):
        super().__init__(message)
        self.status_code = status_code
        self.message = message


@dataclass(frozen=True)
class SmsVerificationMessage:
    phone: str
    code: str
    purpose: str = "register"
    country_code: str = "86"
    valid_seconds: int = 600
    metadata: dict[str, Any] = field(default_factory=dict)


class SmsProvider(Protocol):
    name: str

    async def send_verification_code(self, message: SmsVerificationMessage) -> None:
        """Send one verification code SMS."""

