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

from __future__ import annotations
from .unifiedatsjobinterviewstageoutput import (
    UnifiedAtsJobinterviewstageOutput,
    UnifiedAtsJobinterviewstageOutputTypedDict,
)
from panora_sdk.types import BaseModel, Nullable, UNSET_SENTINEL
from panora_sdk.utils import FieldMetadata, HeaderMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Callable, List, Optional, TypedDict
from typing_extensions import Annotated, NotRequired


class ListAtsJobInterviewStageRequestTypedDict(TypedDict):
    x_connection_token: str
    r"""The connection token"""
    remote_data: NotRequired[bool]
    r"""Set to true to include data from the original software."""
    limit: NotRequired[float]
    r"""Set to get the number of records."""
    cursor: NotRequired[str]
    r"""Set to get the number of records after this cursor."""


class ListAtsJobInterviewStageRequest(BaseModel):
    x_connection_token: Annotated[
        str,
        pydantic.Field(alias="x-connection-token"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ]
    r"""The connection token"""

    remote_data: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Set to true to include data from the original software."""

    limit: Annotated[
        Optional[float],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 50
    r"""Set to get the number of records."""

    cursor: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Set to get the number of records after this cursor."""


class ListAtsJobInterviewStageResponseBodyTypedDict(TypedDict):
    prev_cursor: Nullable[str]
    next_cursor: Nullable[str]
    data: List[UnifiedAtsJobinterviewstageOutputTypedDict]


class ListAtsJobInterviewStageResponseBody(BaseModel):
    prev_cursor: Nullable[str]

    next_cursor: Nullable[str]

    data: List[UnifiedAtsJobinterviewstageOutput]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["prev_cursor", "next_cursor"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

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

            optional_nullable = k in optional_fields and k in nullable_fields
            is_set = (
                self.__pydantic_fields_set__.intersection({n})
                or k in null_default_fields
            )  # pylint: disable=no-member

            if val is not None and val != UNSET_SENTINEL:
                m[k] = val
            elif val != UNSET_SENTINEL and (
                not k in optional_fields or (optional_nullable and is_set)
            ):
                m[k] = val

        return m


class ListAtsJobInterviewStageResponseTypedDict(TypedDict):
    result: ListAtsJobInterviewStageResponseBodyTypedDict


class ListAtsJobInterviewStageResponse(BaseModel):
    next: Callable[[], Optional[ListAtsJobInterviewStageResponse]]

    result: ListAtsJobInterviewStageResponseBody
