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

from __future__ import annotations
from datetime import datetime
from paygentic_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
import pydantic
from pydantic import model_serializer
from typing_extensions import Annotated, NotRequired, TypedDict


class TestClockTypedDict(TypedDict):
    __test__ = False  # pyright: ignore[reportGeneralTypeIssues]

    id: str
    r"""Unique identifier for the test clock"""
    created_at: datetime
    r"""When the test clock was created"""
    current_time: datetime
    r"""The simulated current time of the test clock"""
    merchant_id: str
    r"""The merchant organization that owns this test clock"""
    updated_at: datetime
    r"""When the test clock was last updated"""
    deleted_at: NotRequired[Nullable[datetime]]
    r"""When the test clock was deleted (if applicable)"""
    description: NotRequired[Nullable[str]]
    r"""Description of the test clock's purpose"""
    name: NotRequired[Nullable[str]]
    r"""Name of the test clock"""


class TestClock(BaseModel):
    __test__ = False

    id: str
    r"""Unique identifier for the test clock"""

    created_at: Annotated[datetime, pydantic.Field(alias="createdAt")]
    r"""When the test clock was created"""

    current_time: Annotated[datetime, pydantic.Field(alias="currentTime")]
    r"""The simulated current time of the test clock"""

    merchant_id: Annotated[str, pydantic.Field(alias="merchantId")]
    r"""The merchant organization that owns this test clock"""

    updated_at: Annotated[datetime, pydantic.Field(alias="updatedAt")]
    r"""When the test clock was last updated"""

    deleted_at: Annotated[
        OptionalNullable[datetime], pydantic.Field(alias="deletedAt")
    ] = UNSET
    r"""When the test clock was deleted (if applicable)"""

    description: OptionalNullable[str] = UNSET
    r"""Description of the test clock's purpose"""

    name: OptionalNullable[str] = UNSET
    r"""Name of the test clock"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["deletedAt", "description", "name"])
        nullable_fields = set(["deletedAt", "description", "name"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


try:
    TestClock.model_rebuild()
except NameError:
    pass
