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

from __future__ import annotations
from datetime import datetime
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
import pydantic
from pydantic import model_serializer
from typing import Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class CreateTestClockRequestTypedDict(TypedDict):
    current_time: NotRequired[datetime]
    r"""Initial time for the test clock (defaults to current time). Cannot be more than 1 hour in the past to prevent accidental backdating. The 1-hour buffer accounts for clock drift and network delays."""
    description: NotRequired[str]
    r"""Description of the test clock's purpose"""
    merchant_id: NotRequired[str]
    r"""The merchant organization that will own this test clock. If not provided, will be extracted from authenticated user's context."""
    name: NotRequired[str]
    r"""Name of the test clock"""


class CreateTestClockRequest(BaseModel):
    current_time: Annotated[Optional[datetime], pydantic.Field(alias="currentTime")] = (
        None
    )
    r"""Initial time for the test clock (defaults to current time). Cannot be more than 1 hour in the past to prevent accidental backdating. The 1-hour buffer accounts for clock drift and network delays."""

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

    merchant_id: Annotated[Optional[str], pydantic.Field(alias="merchantId")] = None
    r"""The merchant organization that will own this test clock. If not provided, will be extracted from authenticated user's context."""

    name: Optional[str] = None
    r"""Name of the test clock"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["currentTime", "description", "merchantId", "name"])
        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:
                if val is not None or k not in optional_fields:
                    m[k] = val

        return m


try:
    CreateTestClockRequest.model_rebuild()
except NameError:
    pass
