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

from __future__ import annotations
from .common_v4_pageinfo import CommonV4PageInfo, CommonV4PageInfoTypedDict
from .v4_overrideresponse import V4OverrideResponse, V4OverrideResponseTypedDict
import pydantic
from pydantic import model_serializer
from squadcast.types import BaseModel, UNSET_SENTINEL
from squadcast.utils import FieldMetadata, PathParamMetadata, QueryParamMetadata
from typing import List, Optional
from typing_extensions import Annotated, NotRequired, TypedDict


class OverridesListOverridesRequestTypedDict(TypedDict):
    schedule_id: str
    start_time: str
    end_time: str
    participant_id: NotRequired[str]
    page_size: NotRequired[int]
    cursor: NotRequired[str]


class OverridesListOverridesRequest(BaseModel):
    schedule_id: Annotated[
        str,
        pydantic.Field(alias="scheduleID"),
        FieldMetadata(path=PathParamMetadata(style="simple", explode=False)),
    ]

    start_time: Annotated[
        str,
        pydantic.Field(alias="startTime"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ]

    end_time: Annotated[
        str,
        pydantic.Field(alias="endTime"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ]

    participant_id: Annotated[
        Optional[str],
        pydantic.Field(alias="participantID"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    page_size: Annotated[
        Optional[int],
        pydantic.Field(alias="pageSize"),
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    cursor: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["participantID", "pageSize", "cursor"])
        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 OverridesListOverridesResponseTypedDict(TypedDict):
    r"""The request has succeeded."""

    data: List[V4OverrideResponseTypedDict]
    page_info: NotRequired[CommonV4PageInfoTypedDict]


class OverridesListOverridesResponse(BaseModel):
    r"""The request has succeeded."""

    data: List[V4OverrideResponse]

    page_info: Annotated[
        Optional[CommonV4PageInfo], pydantic.Field(alias="pageInfo")
    ] = None

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["pageInfo"])
        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:
    OverridesListOverridesResponse.model_rebuild()
except NameError:
    pass
