"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

from __future__ import annotations
from attio.types import BaseModel, Nullable, UNSET_SENTINEL
from pydantic import model_serializer
from typing_extensions import TypedDict


class ObjectIDTypedDict(TypedDict):
    workspace_id: str
    r"""A UUID to identify the workspace this object belongs to."""
    object_id: str
    r"""A UUID to identify the object."""


class ObjectID(BaseModel):
    workspace_id: str
    r"""A UUID to identify the workspace this object belongs to."""

    object_id: str
    r"""A UUID to identify the object."""


class ObjectTypedDict(TypedDict):
    id: ObjectIDTypedDict
    api_slug: Nullable[str]
    r"""A unique, human-readable slug to access the object through URLs and API calls. Formatted in snake case."""
    singular_noun: Nullable[str]
    r"""The singular form of the object's name."""
    plural_noun: Nullable[str]
    r"""The plural form of the object's name."""
    created_at: str
    r"""When the object was created."""


class Object(BaseModel):
    id: ObjectID

    api_slug: Nullable[str]
    r"""A unique, human-readable slug to access the object through URLs and API calls. Formatted in snake case."""

    singular_noun: Nullable[str]
    r"""The singular form of the object's name."""

    plural_noun: Nullable[str]
    r"""The plural form of the object's name."""

    created_at: str
    r"""When the object was created."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k, serialized.get(n))

            if val != UNSET_SENTINEL:
                m[k] = val

        return m
