from datetime import datetime
from typing import Optional
from pydantic import BaseModel

from src.db.models.media import MediaActor


class MediaActorResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    name: Optional[str]
    url: Optional[str]

def actor_to_response(actor: MediaActor) -> MediaActorResponse:
    response: MediaActorResponse = MediaActorResponse(
        id=actor.id,
        created_date=actor.created_date,
        last_modified_date=actor.last_modified_date,
        version=actor.version,
        name=actor.name,
        url=actor.url        
    )
    return response


class MediaActorModel(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    name: Optional[str]
    url: Optional[str]
