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

from __future__ import annotations
from .gethrisperformancereviewspositiveresponse import (
    GetHrisPerformanceReviewsPositiveResponse,
    GetHrisPerformanceReviewsPositiveResponseTypedDict,
)
from datetime import datetime
from kombo.types import BaseModel, UNSET_SENTINEL
from kombo.utils import FieldMetadata, HeaderMetadata, QueryParamMetadata
import pydantic
from pydantic import model_serializer
from typing import Awaitable, Callable, List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict


class GetHrisPerformanceReviewsGlobalsTypedDict(TypedDict):
    integration_id: NotRequired[str]
    r"""ID of the integration you want to interact with."""


class GetHrisPerformanceReviewsGlobals(BaseModel):
    integration_id: Annotated[
        Optional[str],
        pydantic.Field(alias="X-Integration-Id"),
        FieldMetadata(header=HeaderMetadata(style="simple", explode=False)),
    ] = None
    r"""ID of the integration you want to interact with."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["integration_id"])
        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 GetHrisPerformanceReviewsRequestTypedDict(TypedDict):
    cursor: NotRequired[str]
    r"""An optional cursor string used for pagination. This can be retrieved from the `next` property of the previous page response."""
    page_size: NotRequired[int]
    r"""The number of results to return per page. Maximum is 250."""
    updated_after: NotRequired[datetime]
    r"""Filter the entries based on the modification date in format `YYYY-MM-DDTHH:mm:ss.sssZ`. Returns records where either the record itself **OR** its nested data has been updated since this timestamp, even if the record's own `changed_at` field remains unchanged.

    If you want to track entry deletion, also set the `include_deleted=true` query parameter, because otherwise, deleted entries will be hidden.

    For more details, see [Understanding changed_at vs updated_after Behavior](https://docs.kombo.dev/ats/getting-started/fetching-data#understanding-changed_at-vs-updated_after-behavior).

    For this endpoint, `updated_after` considers changes to the record itself as well as changes to the following relations:

    - ✓ `review_cycle`
    - ✓ `reviewee`
    - ✓ `reviewer`
    """
    include_deleted: NotRequired[bool]
    r"""By default, deleted entries are not returned. Use the `include_deleted` query param to include deleted entries too."""
    ignore_unsupported_filters: NotRequired[bool]
    r"""When set to `true`, filters targeting fields not supported by this integration will be ignored instead of filtering out all results."""
    ids: NotRequired[List[str]]
    r"""Filter by a comma-separated list of IDs such as `222k7eCGyUdgt2JWZDNnkDs3,B5DVmypWENfU6eMe6gYDyJG3`."""
    remote_ids: NotRequired[List[str]]
    r"""Filter by a comma-separated list of remote IDs."""
    types: NotRequired[List[str]]
    r"""Filter by a comma-separated list of `MANAGER`, `DIRECT_REPORT`, `PEER`, `SELF`

    Leave this blank to get results matching all values.
    """
    review_cycle_ids: NotRequired[List[str]]
    r"""Filter by a comma-separated list of review cycle IDs."""
    reviewee_ids: NotRequired[List[str]]
    r"""Filter by a comma-separated list of reviewee IDs."""


class GetHrisPerformanceReviewsRequest(BaseModel):
    cursor: Annotated[
        Optional[str],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""An optional cursor string used for pagination. This can be retrieved from the `next` property of the previous page response."""

    page_size: Annotated[
        Optional[int],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = 100
    r"""The number of results to return per page. Maximum is 250."""

    updated_after: Annotated[
        Optional[datetime],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = None
    r"""Filter the entries based on the modification date in format `YYYY-MM-DDTHH:mm:ss.sssZ`. Returns records where either the record itself **OR** its nested data has been updated since this timestamp, even if the record's own `changed_at` field remains unchanged.

    If you want to track entry deletion, also set the `include_deleted=true` query parameter, because otherwise, deleted entries will be hidden.

    For more details, see [Understanding changed_at vs updated_after Behavior](https://docs.kombo.dev/ats/getting-started/fetching-data#understanding-changed_at-vs-updated_after-behavior).

    For this endpoint, `updated_after` considers changes to the record itself as well as changes to the following relations:

    - ✓ `review_cycle`
    - ✓ `reviewee`
    - ✓ `reviewer`
    """

    include_deleted: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = False
    r"""By default, deleted entries are not returned. Use the `include_deleted` query param to include deleted entries too."""

    ignore_unsupported_filters: Annotated[
        Optional[bool],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
    ] = False
    r"""When set to `true`, filters targeting fields not supported by this integration will be ignored instead of filtering out all results."""

    ids: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Filter by a comma-separated list of IDs such as `222k7eCGyUdgt2JWZDNnkDs3,B5DVmypWENfU6eMe6gYDyJG3`."""

    remote_ids: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Filter by a comma-separated list of remote IDs."""

    types: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Filter by a comma-separated list of `MANAGER`, `DIRECT_REPORT`, `PEER`, `SELF`

    Leave this blank to get results matching all values.
    """

    review_cycle_ids: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Filter by a comma-separated list of review cycle IDs."""

    reviewee_ids: Annotated[
        Optional[List[str]],
        FieldMetadata(query=QueryParamMetadata(style="form", explode=False)),
    ] = None
    r"""Filter by a comma-separated list of reviewee IDs."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            [
                "cursor",
                "page_size",
                "updated_after",
                "include_deleted",
                "ignore_unsupported_filters",
                "ids",
                "remote_ids",
                "types",
                "review_cycle_ids",
                "reviewee_ids",
            ]
        )
        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 GetHrisPerformanceReviewsResponseTypedDict(TypedDict):
    result: GetHrisPerformanceReviewsPositiveResponseTypedDict


class GetHrisPerformanceReviewsResponse(BaseModel):
    next: Union[
        Callable[[], Optional[GetHrisPerformanceReviewsResponse]],
        Callable[[], Awaitable[Optional[GetHrisPerformanceReviewsResponse]]],
    ]

    result: GetHrisPerformanceReviewsPositiveResponse
