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


class EmailProviderError(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 EmailMessage:
    to: str
    subject: str
    body: str
    subtype: str = "plain"
    metadata: dict[str, Any] = field(default_factory=dict)


class EmailProvider(Protocol):
    name: str

    async def send(self, message: EmailMessage) -> None:
        """Send one email message."""

