from datetime import datetime

from pydantic import BaseModel

from src.db.models.admin import MailAccount


class MailAccountResponse(BaseModel):
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    host: str
    port: int
    protocol: str
    user_name: str
    password: str
    start_tls: bool


def to_response(account: MailAccount) -> MailAccountResponse:
    response: MailAccountResponse = MailAccountResponse(
        id=account.id,
        created_date=account.created_date,
        last_modified_date=account.last_modified_date,
        version=account.version,
        host=account.host,
        port=account.port,
        protocol=account.protocol,
        user_name=account.user_name,
        password=account.password,
        start_tls=account.start_tls,
    )
    return response
