from datetime import datetime
from typing import Optional

from pydantic import BaseModel

from src.db.models.comic import StoryArc

class StoryArcResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    name: str
    comic_id: str
    volume_id: Optional[str]

class AddLink(BaseModel):
    url: str

def storyarc_to_response(storyarc: StoryArc) -> StoryArcResponse:
    response: StoryArcResponse = StoryArcResponse(
        id=storyarc.id,
        created_date=storyarc.created_date,
        last_modified_date=storyarc.last_modified_date,
        version=storyarc.version,
        name=storyarc.name,
        comic_id=storyarc.comic_id,
        volume_id=storyarc.volume_id
    )
    return response
