from datetime import datetime

from pydantic import BaseModel

from src.db.models.tysc import Rooster


class RoosterResponse(BaseModel):
    """
    Pydantic model for returning Rooster objects.
    """
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    year: int
    team_id: str
    player_id: str
    position_id: str


def to_response(rooster: Rooster) -> RoosterResponse:
    """
    convert database object to response object (Pydantic).
    """
    response: RoosterResponse = RoosterResponse(
        id=rooster.id,
        created_date=rooster.created_date,
        last_modified_date=rooster.last_modified_date,
        version=rooster.version,
        year=rooster.year,
        team_id=rooster.team_id,
        player_id=rooster.player_id,
        position_id=rooster.position_id
    )
    return response
