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

from __future__ import annotations
from kombo.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from pydantic import model_serializer
from typing import List, Literal
from typing_extensions import NotRequired, TypedDict


AssessmentOrderReceivedWebhookPayloadType = Literal["assessment:order-received",]
r"""Type of the webhook event"""


AssessmentOrderReceivedWebhookPayloadStatus = Literal[
    "OPEN",
    "COMPLETED",
    "CANCELLED",
    "REJECTED",
]
r"""The current status of the assessment order."""


class AssessmentOrderReceivedWebhookPayloadCandidateTypedDict(TypedDict):
    r"""Information about the candidate taking the assessment."""

    email: str
    r"""The candidate's email address."""
    remote_id: NotRequired[Nullable[str]]
    r"""The candidate's identifier in the integrated system."""
    first_name: NotRequired[Nullable[str]]
    r"""The candidate's first name."""
    last_name: NotRequired[Nullable[str]]
    r"""The candidate's last name."""
    phone: NotRequired[Nullable[str]]
    r"""The candidate's phone number."""


class AssessmentOrderReceivedWebhookPayloadCandidate(BaseModel):
    r"""Information about the candidate taking the assessment."""

    email: str
    r"""The candidate's email address."""

    remote_id: OptionalNullable[str] = UNSET
    r"""The candidate's identifier in the integrated system."""

    first_name: OptionalNullable[str] = UNSET
    r"""The candidate's first name."""

    last_name: OptionalNullable[str] = UNSET
    r"""The candidate's last name."""

    phone: OptionalNullable[str] = UNSET
    r"""The candidate's phone number."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["remote_id", "first_name", "last_name", "phone"])
        nullable_fields = set(["remote_id", "first_name", "last_name", "phone"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            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 AssessmentOrderReceivedWebhookPayloadApplicationTypedDict(TypedDict):
    r"""Information about the job application."""

    remote_id: NotRequired[Nullable[str]]
    r"""The application's identifier in the integrated system."""


class AssessmentOrderReceivedWebhookPayloadApplication(BaseModel):
    r"""Information about the job application."""

    remote_id: OptionalNullable[str] = UNSET
    r"""The application's identifier in the integrated system."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["remote_id"])
        nullable_fields = set(["remote_id"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            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 AssessmentOrderReceivedWebhookPayloadLocationTypedDict(TypedDict):
    r"""The job location information."""

    city: NotRequired[Nullable[str]]
    country: NotRequired[Nullable[str]]
    r"""Contains the ISO2 country code if possible. If not, it contains the original value."""
    raw: NotRequired[Nullable[str]]
    r"""If we have address data, this is filled with the raw address string."""
    state: NotRequired[Nullable[str]]
    street_1: NotRequired[Nullable[str]]
    r"""If we can parse the address data, this field contains the first part of the street information."""
    street_2: NotRequired[Nullable[str]]
    zip_code: NotRequired[Nullable[str]]


class AssessmentOrderReceivedWebhookPayloadLocation(BaseModel):
    r"""The job location information."""

    city: OptionalNullable[str] = UNSET

    country: OptionalNullable[str] = UNSET
    r"""Contains the ISO2 country code if possible. If not, it contains the original value."""

    raw: OptionalNullable[str] = UNSET
    r"""If we have address data, this is filled with the raw address string."""

    state: OptionalNullable[str] = UNSET

    street_1: OptionalNullable[str] = UNSET
    r"""If we can parse the address data, this field contains the first part of the street information."""

    street_2: OptionalNullable[str] = UNSET

    zip_code: OptionalNullable[str] = UNSET

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(
            ["city", "country", "raw", "state", "street_1", "street_2", "zip_code"]
        )
        nullable_fields = set(
            ["city", "country", "raw", "state", "street_1", "street_2", "zip_code"]
        )
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            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


AssessmentOrderReceivedWebhookPayloadHiringTeamRole = Literal[
    "RECRUITER",
    "HIRING_MANAGER",
]


class AssessmentOrderReceivedWebhookPayloadHiringTeamTypedDict(TypedDict):
    r"""A member of the hiring team."""

    remote_id: str
    r"""The team member's identifier in the integrated system."""
    email: Nullable[str]
    r"""The team member's email address."""
    first_name: Nullable[str]
    r"""The team member's first name."""
    last_name: Nullable[str]
    r"""The team member's last name."""
    hiring_team_roles: List[AssessmentOrderReceivedWebhookPayloadHiringTeamRole]
    r"""Array of the roles of the user for this specific job. Currently only `RECRUITER` and `HIRING_MANAGER` are mapped into our unified schema."""


class AssessmentOrderReceivedWebhookPayloadHiringTeam(BaseModel):
    r"""A member of the hiring team."""

    remote_id: str
    r"""The team member's identifier in the integrated system."""

    email: Nullable[str]
    r"""The team member's email address."""

    first_name: Nullable[str]
    r"""The team member's first name."""

    last_name: Nullable[str]
    r"""The team member's last name."""

    hiring_team_roles: List[AssessmentOrderReceivedWebhookPayloadHiringTeamRole]
    r"""Array of the roles of the user for this specific job. Currently only `RECRUITER` and `HIRING_MANAGER` are mapped into our unified schema."""

    @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)

            if val != UNSET_SENTINEL:
                m[k] = val

        return m


class AssessmentOrderReceivedWebhookPayloadJobTypedDict(TypedDict):
    r"""Information about the job posting."""

    hiring_team: List[AssessmentOrderReceivedWebhookPayloadHiringTeamTypedDict]
    r"""The hiring team allows you to provision users into your system who can access the job and its applications."""
    remote_id: NotRequired[Nullable[str]]
    r"""The job's identifier in the integrated system."""
    name: NotRequired[Nullable[str]]
    r"""The job title."""
    location: NotRequired[
        Nullable[AssessmentOrderReceivedWebhookPayloadLocationTypedDict]
    ]
    r"""The job location information."""


class AssessmentOrderReceivedWebhookPayloadJob(BaseModel):
    r"""Information about the job posting."""

    hiring_team: List[AssessmentOrderReceivedWebhookPayloadHiringTeam]
    r"""The hiring team allows you to provision users into your system who can access the job and its applications."""

    remote_id: OptionalNullable[str] = UNSET
    r"""The job's identifier in the integrated system."""

    name: OptionalNullable[str] = UNSET
    r"""The job title."""

    location: OptionalNullable[AssessmentOrderReceivedWebhookPayloadLocation] = UNSET
    r"""The job location information."""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = set(["remote_id", "name", "location"])
        nullable_fields = set(["remote_id", "name", "location"])
        serialized = handler(self)
        m = {}

        for n, f in type(self).model_fields.items():
            k = f.alias or n
            val = serialized.get(k)
            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 AssessmentOrderReceivedWebhookPayloadDataTypedDict(TypedDict):
    id: str
    r"""The unique identifier of the assessment order."""
    package_id: str
    r"""The identifier of the assessment package."""
    status: AssessmentOrderReceivedWebhookPayloadStatus
    r"""The current status of the assessment order."""
    integration_id: str
    r"""The unique identifier of the integration."""
    candidate: AssessmentOrderReceivedWebhookPayloadCandidateTypedDict
    r"""Information about the candidate taking the assessment."""
    application: AssessmentOrderReceivedWebhookPayloadApplicationTypedDict
    r"""Information about the job application."""
    job: AssessmentOrderReceivedWebhookPayloadJobTypedDict
    r"""Information about the job posting."""


class AssessmentOrderReceivedWebhookPayloadData(BaseModel):
    id: str
    r"""The unique identifier of the assessment order."""

    package_id: str
    r"""The identifier of the assessment package."""

    status: AssessmentOrderReceivedWebhookPayloadStatus
    r"""The current status of the assessment order."""

    integration_id: str
    r"""The unique identifier of the integration."""

    candidate: AssessmentOrderReceivedWebhookPayloadCandidate
    r"""Information about the candidate taking the assessment."""

    application: AssessmentOrderReceivedWebhookPayloadApplication
    r"""Information about the job application."""

    job: AssessmentOrderReceivedWebhookPayloadJob
    r"""Information about the job posting."""


class AssessmentOrderReceivedWebhookPayloadTypedDict(TypedDict):
    id: str
    r"""Unique identifier for this webhook event"""
    type: AssessmentOrderReceivedWebhookPayloadType
    r"""Type of the webhook event"""
    data: AssessmentOrderReceivedWebhookPayloadDataTypedDict


class AssessmentOrderReceivedWebhookPayload(BaseModel):
    id: str
    r"""Unique identifier for this webhook event"""

    type: AssessmentOrderReceivedWebhookPayloadType
    r"""Type of the webhook event"""

    data: AssessmentOrderReceivedWebhookPayloadData
