from datetime import datetime
from typing import Optional

from pydantic import BaseModel

from src.db.models.media import MediaArticle

class MediaArticleResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    review: bool = False
    title: Optional[str] = None
    url: Optional[str] = None

class AddLink(BaseModel):
    url: str

def to_response(video: MediaArticle) -> MediaArticleResponse:
    response: MediaArticleResponse = MediaArticleResponse(
        id=video.id,
        created_date=video.created_date,
        last_modified_date=video.last_modified_date,
        version=video.version,
        review=video.review,
        title=video.title,
        url=video.url,
    )
    return response
