"""Authentication schemas."""

from dataclasses import dataclass, asdict
from datetime import datetime


@dataclass
class TokenPayload:
    """JWT token payload."""

    sub: str  # Subject (user identifier)
    exp: datetime  # Expiration time
    iat: datetime  # Issued at time

    def to_dict(self) -> dict:
        """Convert to dictionary for JWT encoding."""
        return {
            "sub": self.sub,
            "exp": int(self.exp.timestamp()),
            "iat": int(self.iat.timestamp()),
        }


@dataclass
class UserLogin:
    """User login request."""

    username: str
    password: str


@dataclass
class UserToken:
    """Token response."""

    access_token: str
    token_type: str = "bearer"
