from datetime import datetime

from pydantic import BaseModel

from src.db.models.admin import Token


class TokenResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    token: str
    name: str
    last_used_date: datetime
    enabled: bool
    profile_id: str


def to_response(token: Token) -> TokenResponse:
    response: TokenResponse = TokenResponse(
        id=token.id,
        created_date=token.created_date,
        last_modified_date=token.last_modified_date,
        version=token.version,
        token=token.token,
        name=token.name,
        last_used_date=token.last_used_date,
        enabled=token.enabled,
        profile_id=token.profile_id
    )
    return response
