"""Request, response, and patch schemas for Telegram media files."""
from __future__ import annotations

from datetime import datetime

from repo_core.base.schemas import (
    BaseRequestSchema,
    BaseResponseSchema,
    BasePatchSchema,
)


class CreateMediaFileRequest(BaseRequestSchema):
    """Validated payload for recording a successfully downloaded media file."""

    peer_id: int
    message_id: int
    storage_key: str
    bucket: str
    file_size: int
    mime_type: str
    media_type: str
    width: int | None = None
    height: int | None = None
    duration_seconds: float | None = None
    downloaded_at: datetime


class MediaFileResponse(BaseResponseSchema):
    """Serialised media file record returned to API callers."""

    peer_id: int
    message_id: int
    storage_key: str
    bucket: str | None = None
    file_size: int
    mime_type: str
    media_type: str
    width: int | None = None
    height: int | None = None
    duration_seconds: float | None = None
    downloaded_at: datetime
    created_at: datetime | None = None
    updated_at: datetime | None = None


class PatchMediaFileRequest(BasePatchSchema):
    """Partial update payload for an existing media file record."""

    storage_key: str | None = None
    bucket: str | None = None
    file_size: int | None = None
    mime_type: str | None = None
    width: int | None = None
    height: int | None = None
    duration_seconds: float | None = None
