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

from __future__ import annotations
from .testclock import TestClock, TestClockTypedDict
from paygentic_sdk.types import BaseModel, UNSET_SENTINEL
from paygentic_sdk.utils import FieldMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class ListTestClocksRequestTypedDict(TypedDict):
    limit: NotRequired[int]
    r"""Number of items to return"""
    merchant_id: NotRequired[str]
    r"""Filter test clocks by merchant ID. If not provided, will be extracted from authenticated user's context."""
    offset: NotRequired[int]
    r"""Number of items to skip"""


class ListTestClocksRequest(BaseModel):
    limit: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 10
    r"""Number of items to return"""

    merchant_id: Annotated[
        Optional[str],
        pydantic.Field(alias="merchantId"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter test clocks by merchant ID. If not provided, will be extracted from authenticated user's context."""

    offset: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 0
    r"""Number of items to skip"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["limit", "merchantId", "offset"])
        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


class ListTestClocksPaginationTypedDict(TypedDict):
    limit: NotRequired[int]
    r"""Number of items per page"""
    offset: NotRequired[int]
    r"""Number of items skipped"""
    total: NotRequired[int]
    r"""Total number of test clocks"""


class ListTestClocksPagination(BaseModel):
    limit: Optional[int] = None
    r"""Number of items per page"""

    offset: Optional[int] = None
    r"""Number of items skipped"""

    total: Optional[int] = None
    r"""Total number of test clocks"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["limit", "offset", "total"])
        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


class ListTestClocksResponseTypedDict(TypedDict):
    r"""List of test clocks"""

    data: NotRequired[List[TestClockTypedDict]]
    pagination: NotRequired[ListTestClocksPaginationTypedDict]


class ListTestClocksResponse(BaseModel):
    r"""List of test clocks"""

    data: Optional[List[TestClock]] = None

    pagination: Optional[ListTestClocksPagination] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["data", "pagination"])
        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
