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

from __future__ import annotations
from .email import Email, EmailTypedDict
from .phone import Phone, PhoneTypedDict
from .unifiedatsapplicationoutput import (
    UnifiedAtsApplicationOutput,
    UnifiedAtsApplicationOutputTypedDict,
)
from .unifiedatsattachmentoutput import (
    UnifiedAtsAttachmentOutput,
    UnifiedAtsAttachmentOutputTypedDict,
)
from .unifiedatstagoutput import UnifiedAtsTagOutput, UnifiedAtsTagOutputTypedDict
from .url import URL, URLTypedDict
from datetime import datetime
from panora_sdk.types import (
    BaseModel,
    Nullable,
    OptionalNullable,
    UNSET,
    UNSET_SENTINEL,
)
from pydantic import model_serializer
from typing import Any, Dict, List, TypedDict, Union
from typing_extensions import NotRequired


UnifiedAtsCandidateOutputAttachmentsTypedDict = Union[
    UnifiedAtsAttachmentOutputTypedDict, str
]


UnifiedAtsCandidateOutputAttachments = Union[UnifiedAtsAttachmentOutput, str]


ApplicationsModelTypedDict = Union[UnifiedAtsApplicationOutputTypedDict, str]


ApplicationsModel = Union[UnifiedAtsApplicationOutput, str]


UnifiedAtsCandidateOutputTagsTypedDict = Union[UnifiedAtsTagOutputTypedDict, str]


UnifiedAtsCandidateOutputTags = Union[UnifiedAtsTagOutput, str]


class UnifiedAtsCandidateOutputTypedDict(TypedDict):
    first_name: NotRequired[Nullable[str]]
    r"""The first name of the candidate"""
    last_name: NotRequired[Nullable[str]]
    r"""The last name of the candidate"""
    company: NotRequired[Nullable[str]]
    r"""The company of the candidate"""
    title: NotRequired[Nullable[str]]
    r"""The title of the candidate"""
    locations: NotRequired[Nullable[str]]
    r"""The locations of the candidate"""
    is_private: NotRequired[Nullable[bool]]
    r"""Whether the candidate is private"""
    email_reachable: NotRequired[Nullable[bool]]
    r"""Whether the candidate is reachable by email"""
    remote_created_at: NotRequired[Nullable[datetime]]
    r"""The remote creation date of the candidate"""
    remote_modified_at: NotRequired[Nullable[datetime]]
    r"""The remote modification date of the candidate"""
    last_interaction_at: NotRequired[Nullable[datetime]]
    r"""The last interaction date with the candidate"""
    attachments: NotRequired[
        Nullable[List[UnifiedAtsCandidateOutputAttachmentsTypedDict]]
    ]
    r"""The attachments UUIDs of the candidate"""
    applications: NotRequired[Nullable[List[ApplicationsModelTypedDict]]]
    r"""The applications UUIDs of the candidate"""
    tags: NotRequired[Nullable[List[UnifiedAtsCandidateOutputTagsTypedDict]]]
    r"""The tags of the candidate"""
    urls: NotRequired[Nullable[List[URLTypedDict]]]
    r"""The urls of the candidate, possible values for Url type are WEBSITE, BLOG, LINKEDIN, GITHUB, or OTHER"""
    phone_numbers: NotRequired[Nullable[List[PhoneTypedDict]]]
    r"""The phone numbers of the candidate"""
    email_addresses: NotRequired[Nullable[List[EmailTypedDict]]]
    r"""The email addresses of the candidate"""
    field_mappings: NotRequired[Nullable[Dict[str, Any]]]
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""
    id: NotRequired[Nullable[str]]
    r"""The UUID of the candidate"""
    remote_id: NotRequired[Nullable[str]]
    r"""The id of the candidate in the context of the 3rd Party"""
    remote_data: NotRequired[Nullable[Dict[str, Any]]]
    r"""The remote data of the candidate in the context of the 3rd Party"""
    created_at: NotRequired[Nullable[datetime]]
    r"""The created date of the object"""
    modified_at: NotRequired[Nullable[datetime]]
    r"""The modified date of the object"""


class UnifiedAtsCandidateOutput(BaseModel):
    first_name: OptionalNullable[str] = UNSET
    r"""The first name of the candidate"""

    last_name: OptionalNullable[str] = UNSET
    r"""The last name of the candidate"""

    company: OptionalNullable[str] = UNSET
    r"""The company of the candidate"""

    title: OptionalNullable[str] = UNSET
    r"""The title of the candidate"""

    locations: OptionalNullable[str] = UNSET
    r"""The locations of the candidate"""

    is_private: OptionalNullable[bool] = UNSET
    r"""Whether the candidate is private"""

    email_reachable: OptionalNullable[bool] = UNSET
    r"""Whether the candidate is reachable by email"""

    remote_created_at: OptionalNullable[datetime] = UNSET
    r"""The remote creation date of the candidate"""

    remote_modified_at: OptionalNullable[datetime] = UNSET
    r"""The remote modification date of the candidate"""

    last_interaction_at: OptionalNullable[datetime] = UNSET
    r"""The last interaction date with the candidate"""

    attachments: OptionalNullable[List[UnifiedAtsCandidateOutputAttachments]] = UNSET
    r"""The attachments UUIDs of the candidate"""

    applications: OptionalNullable[List[ApplicationsModel]] = UNSET
    r"""The applications UUIDs of the candidate"""

    tags: OptionalNullable[List[UnifiedAtsCandidateOutputTags]] = UNSET
    r"""The tags of the candidate"""

    urls: OptionalNullable[List[URL]] = UNSET
    r"""The urls of the candidate, possible values for Url type are WEBSITE, BLOG, LINKEDIN, GITHUB, or OTHER"""

    phone_numbers: OptionalNullable[List[Phone]] = UNSET
    r"""The phone numbers of the candidate"""

    email_addresses: OptionalNullable[List[Email]] = UNSET
    r"""The email addresses of the candidate"""

    field_mappings: OptionalNullable[Dict[str, Any]] = UNSET
    r"""The custom field mappings of the object between the remote 3rd party & Panora"""

    id: OptionalNullable[str] = UNSET
    r"""The UUID of the candidate"""

    remote_id: OptionalNullable[str] = UNSET
    r"""The id of the candidate in the context of the 3rd Party"""

    remote_data: OptionalNullable[Dict[str, Any]] = UNSET
    r"""The remote data of the candidate in the context of the 3rd Party"""

    created_at: OptionalNullable[datetime] = UNSET
    r"""The created date of the object"""

    modified_at: OptionalNullable[datetime] = UNSET
    r"""The modified date of the object"""

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = [
            "first_name",
            "last_name",
            "company",
            "title",
            "locations",
            "is_private",
            "email_reachable",
            "remote_created_at",
            "remote_modified_at",
            "last_interaction_at",
            "attachments",
            "applications",
            "tags",
            "urls",
            "phone_numbers",
            "email_addresses",
            "field_mappings",
            "id",
            "remote_id",
            "remote_data",
            "created_at",
            "modified_at",
        ]
        nullable_fields = [
            "first_name",
            "last_name",
            "company",
            "title",
            "locations",
            "is_private",
            "email_reachable",
            "remote_created_at",
            "remote_modified_at",
            "last_interaction_at",
            "attachments",
            "applications",
            "tags",
            "urls",
            "phone_numbers",
            "email_addresses",
            "field_mappings",
            "id",
            "remote_id",
            "remote_data",
            "created_at",
            "modified_at",
        ]
        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
