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

from __future__ import annotations
from datetime import datetime
from kombo.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from kombo.utils import validate_const
import pydantic
from pydantic import model_serializer
from pydantic.functional_validators import AfterValidator
from typing import List, Literal
from typing_extensions import Annotated, NotRequired, TypedDict


GetAtsUsersPositiveResponseStatus = Literal[
    "ACTIVE",
    "INACTIVE",
]
r"""Whether the user is active or inactive. Consider this field when provisioning users from the ATS."""


GetAtsUsersPositiveResponseScope = Literal[
    "SYSTEM",
    "JOB",
]
r"""Whether the role applies globally or is scoped to a specific job."""


GetAtsUsersPositiveResponseUnifiedType = Literal[
    "HIRING_MANAGER",
    "RECRUITER",
    "COORDINATOR",
    "SOURCER",
    "INTERVIEWER",
    "ADMIN",
]
r"""Unified role type if Kombo can map it."""


class SystemRoleTypedDict(TypedDict):
    remote_id: Nullable[str]
    r"""The raw ID of the object in the remote system. We don't recommend using this as a primary key on your side as it might sometimes be compromised of multiple identifiers if a system doesn't provide a clear primary key."""
    remote_label: Nullable[str]
    r"""The label of the role."""
    scope: Nullable[GetAtsUsersPositiveResponseScope]
    r"""Whether the role applies globally or is scoped to a specific job."""
    unified_type: Nullable[GetAtsUsersPositiveResponseUnifiedType]
    r"""Unified role type if Kombo can map it."""


class SystemRole(BaseModel):
    remote_id: Nullable[str]
    r"""The raw ID of the object in the remote system. We don't recommend using this as a primary key on your side as it might sometimes be compromised of multiple identifiers if a system doesn't provide a clear primary key."""

    remote_label: Nullable[str]
    r"""The label of the role."""

    scope: Nullable[GetAtsUsersPositiveResponseScope]
    r"""Whether the role applies globally or is scoped to a specific job."""

    unified_type: Nullable[GetAtsUsersPositiveResponseUnifiedType]
    r"""Unified role type if Kombo can map it."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


class GetAtsUsersPositiveResponseResultTypedDict(TypedDict):
    id: str
    r"""The globally unique ID of this object generated by Kombo. We recommend using this as a stable primary key for syncing."""
    remote_id: Nullable[str]
    r"""The raw ID of the object in the remote system. We don't recommend using this as a primary key on your side as it might sometimes be compromised of multiple identifiers if a system doesn't provide a clear primary key."""
    first_name: Nullable[str]
    r"""First name of the user."""
    last_name: Nullable[str]
    r"""Last name of the user."""
    status: Nullable[GetAtsUsersPositiveResponseStatus]
    r"""Whether the user is active or inactive. Consider this field when provisioning users from the ATS."""
    changed_at: datetime
    r"""The timestamp when this specific record was last modified. This field only updates when properties directly on this record change, NOT when related or nested models change. For filtering that considers nested data changes, use the `updated_after` parameter which will return records when either the record itself OR its related models have been updated.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """
    remote_deleted_at: Nullable[datetime]
    r"""The date and time the object was deleted in the remote system. Objects are automatically marked as deleted when Kombo can't retrieve them from the remote system anymore. Kombo will also anonymize entries 14 days after they disappear.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """
    system_roles: List[SystemRoleTypedDict]
    r"""System-wide roles assigned to this user in the ATS.

    Visit our in-depth guide about [roles](/ats/features/roles) to learn more.

    Note: Use `job_roles` on the `/v1/ats/jobs` endpoint for job-specific roles.
    """
    email: NotRequired[Nullable[str]]
    r"""Email of the user. If the email address is invalid, it will be set to null."""


class GetAtsUsersPositiveResponseResult(BaseModel):
    id: str
    r"""The globally unique ID of this object generated by Kombo. We recommend using this as a stable primary key for syncing."""

    remote_id: Nullable[str]
    r"""The raw ID of the object in the remote system. We don't recommend using this as a primary key on your side as it might sometimes be compromised of multiple identifiers if a system doesn't provide a clear primary key."""

    first_name: Nullable[str]
    r"""First name of the user."""

    last_name: Nullable[str]
    r"""Last name of the user."""

    status: Nullable[GetAtsUsersPositiveResponseStatus]
    r"""Whether the user is active or inactive. Consider this field when provisioning users from the ATS."""

    changed_at: datetime
    r"""The timestamp when this specific record was last modified. This field only updates when properties directly on this record change, NOT when related or nested models change. For filtering that considers nested data changes, use the `updated_after` parameter which will return records when either the record itself OR its related models have been updated.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """

    remote_deleted_at: Nullable[datetime]
    r"""The date and time the object was deleted in the remote system. Objects are automatically marked as deleted when Kombo can't retrieve them from the remote system anymore. Kombo will also anonymize entries 14 days after they disappear.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """

    system_roles: List[SystemRole]
    r"""System-wide roles assigned to this user in the ATS.

    Visit our in-depth guide about [roles](/ats/features/roles) to learn more.

    Note: Use `job_roles` on the `/v1/ats/jobs` endpoint for job-specific roles.
    """

    email: OptionalNullable[str] = UNSET
    r"""Email of the user. If the email address is invalid, it will be set to null."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["email"])
        nullable_fields = set(
            [
                "remote_id",
                "first_name",
                "last_name",
                "email",
                "status",
                "remote_deleted_at",
            ]
        )
        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))
            is_nullable_and_explicitly_set = (
                k in nullable_fields
                and (self.__pydantic_fields_set__.intersection({n}))  # pylint: disable=no-member
            )

            if val != UNSET_SENTINEL:
                if (
                    val is not None
                    or k not in optional_fields
                    or is_nullable_and_explicitly_set
                ):
                    m[k] = val

        return m


class GetAtsUsersPositiveResponseDataTypedDict(TypedDict):
    next: Nullable[str]
    r"""Cursor string that can be passed to the `cursor` query parameter to get the next page. If this is `null`, then there are no more pages."""
    results: List[GetAtsUsersPositiveResponseResultTypedDict]


class GetAtsUsersPositiveResponseData(BaseModel):
    next: Nullable[str]
    r"""Cursor string that can be passed to the `cursor` query parameter to get the next page. If this is `null`, then there are no more pages."""

    results: List[GetAtsUsersPositiveResponseResult]

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        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:
                m[k] = val

        return m


class GetAtsUsersPositiveResponseTypedDict(TypedDict):
    data: GetAtsUsersPositiveResponseDataTypedDict
    status: Literal["success"]


class GetAtsUsersPositiveResponse(BaseModel):
    data: GetAtsUsersPositiveResponseData

    STATUS: Annotated[
        Annotated[Literal["success"], AfterValidator(validate_const("success"))],
        pydantic.Field(alias="status"),
    ] = "success"


try:
    GetAtsUsersPositiveResponse.model_rebuild()
except NameError:
    pass
