"""
class and function for json response objects for Vendor.
"""
from datetime import datetime

from pydantic import BaseModel

from src.db.models.tysc import Vendor


class VendorResponse(BaseModel):
    """
    Pydantic model for Vendor reponse object.
    """
    id: str
    created_date: datetime
    last_modified_date: datetime
    version: int
    name: str

def to_response(vendor: Vendor) -> VendorResponse:
    """
    convert database object Vendor to response object VendorResponse.
    """
    reponse: VendorResponse = VendorResponse(
        id=vendor.id,
        created_date=vendor.created_date,
        last_modified_date=vendor.last_modified_date,
        version=vendor.version,
        name=vendor.name
    )
    return reponse
