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

from __future__ import annotations
from datetime import datetime
from kombo.types import BaseModel, Nullable, 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, TypedDict


GetAtsCandidatesCandidateIDAttachmentsPositiveResponseType = Literal[
    "CV",
    "COVER_LETTER",
    "OTHER",
]


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponseResultTypedDict(TypedDict):
    id: str
    application_id: Nullable[str]
    r"""The Kombo ID of the application this attachment belongs to. When this is null, the attachment is not specific to any application but the candidate."""
    candidate_id: str
    r"""The Kombo ID of the candidate this attachment belongs to."""
    type: GetAtsCandidatesCandidateIDAttachmentsPositiveResponseType
    remote_id: str
    data_url: str
    file_name: str
    content_type: str
    r"""The MIME type of the attachment."""
    remote_created_at: Nullable[datetime]
    r"""The date when the attachment was created.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """
    remote_updated_at: Nullable[datetime]
    r"""The date when the attachment was last updated.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponseResult(BaseModel):
    id: str

    application_id: Nullable[str]
    r"""The Kombo ID of the application this attachment belongs to. When this is null, the attachment is not specific to any application but the candidate."""

    candidate_id: str
    r"""The Kombo ID of the candidate this attachment belongs to."""

    type: GetAtsCandidatesCandidateIDAttachmentsPositiveResponseType

    remote_id: str

    data_url: str

    file_name: str

    content_type: str
    r"""The MIME type of the attachment."""

    remote_created_at: Nullable[datetime]
    r"""The date when the attachment was created.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """

    remote_updated_at: Nullable[datetime]
    r"""The date when the attachment was last updated.
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
    """

    @model_serializer(mode="wrap")
    def serialize_model(self, handler):
        optional_fields = []
        nullable_fields = ["application_id", "remote_created_at", "remote_updated_at"]
        null_default_fields = []

        serialized = handler(self)

        m = {}

        for n, f in type(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 GetAtsCandidatesCandidateIDAttachmentsPositiveResponseDataTypedDict(TypedDict):
    results: List[GetAtsCandidatesCandidateIDAttachmentsPositiveResponseResultTypedDict]


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponseData(BaseModel):
    results: List[GetAtsCandidatesCandidateIDAttachmentsPositiveResponseResult]


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponseWarningTypedDict(TypedDict):
    message: str


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponseWarning(BaseModel):
    message: str


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponseTypedDict(TypedDict):
    data: GetAtsCandidatesCandidateIDAttachmentsPositiveResponseDataTypedDict
    warnings: List[
        GetAtsCandidatesCandidateIDAttachmentsPositiveResponseWarningTypedDict
    ]
    r"""These are the interaction warnings that are shown in the dashboard. They are meant to provide debug information to you. We recommend logging them to the console."""
    status: Literal["success"]


class GetAtsCandidatesCandidateIDAttachmentsPositiveResponse(BaseModel):
    data: GetAtsCandidatesCandidateIDAttachmentsPositiveResponseData

    warnings: List[GetAtsCandidatesCandidateIDAttachmentsPositiveResponseWarning]
    r"""These are the interaction warnings that are shown in the dashboard. They are meant to provide debug information to you. We recommend logging them to the console."""

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