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

from __future__ import annotations
from .unifiedticketingattachmentoutput import (
    UnifiedTicketingAttachmentOutput,
    UnifiedTicketingAttachmentOutputTypedDict,
)
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


UnifiedTicketingCommentOutputAttachmentsTypedDict = Union[
    UnifiedTicketingAttachmentOutputTypedDict, str
]


UnifiedTicketingCommentOutputAttachments = Union[UnifiedTicketingAttachmentOutput, str]


class UnifiedTicketingCommentOutputTypedDict(TypedDict):
    body: Nullable[str]
    r"""The body of the comment"""
    html_body: NotRequired[Nullable[str]]
    r"""The html body of the comment"""
    is_private: NotRequired[Nullable[bool]]
    r"""The public status of the comment"""
    creator_type: NotRequired[Nullable[str]]
    r"""The creator type of the comment. Authorized values are either USER or CONTACT"""
    ticket_id: NotRequired[Nullable[str]]
    r"""The UUID of the ticket the comment is tied to"""
    contact_id: NotRequired[Nullable[str]]
    r"""The UUID of the contact which the comment belongs to (if no user_id specified)"""
    user_id: NotRequired[Nullable[str]]
    r"""The UUID of the user which the comment belongs to (if no contact_id specified)"""
    attachments: NotRequired[
        Nullable[List[UnifiedTicketingCommentOutputAttachmentsTypedDict]]
    ]
    r"""The attachements UUIDs tied to the comment"""
    id: NotRequired[Nullable[str]]
    r"""The UUID of the comment"""
    remote_id: NotRequired[Nullable[str]]
    r"""The id of the comment in the context of the 3rd Party"""
    remote_data: NotRequired[Nullable[Dict[str, Any]]]
    r"""The remote data of the comment 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 UnifiedTicketingCommentOutput(BaseModel):
    body: Nullable[str]
    r"""The body of the comment"""

    html_body: OptionalNullable[str] = UNSET
    r"""The html body of the comment"""

    is_private: OptionalNullable[bool] = UNSET
    r"""The public status of the comment"""

    creator_type: OptionalNullable[str] = UNSET
    r"""The creator type of the comment. Authorized values are either USER or CONTACT"""

    ticket_id: OptionalNullable[str] = UNSET
    r"""The UUID of the ticket the comment is tied to"""

    contact_id: OptionalNullable[str] = UNSET
    r"""The UUID of the contact which the comment belongs to (if no user_id specified)"""

    user_id: OptionalNullable[str] = UNSET
    r"""The UUID of the user which the comment belongs to (if no contact_id specified)"""

    attachments: OptionalNullable[List[UnifiedTicketingCommentOutputAttachments]] = (
        UNSET
    )
    r"""The attachements UUIDs tied to the comment"""

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

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

    remote_data: OptionalNullable[Dict[str, Any]] = UNSET
    r"""The remote data of the comment 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 = [
            "html_body",
            "is_private",
            "creator_type",
            "ticket_id",
            "contact_id",
            "user_id",
            "attachments",
            "id",
            "remote_id",
            "remote_data",
            "created_at",
            "modified_at",
        ]
        nullable_fields = [
            "body",
            "html_body",
            "is_private",
            "creator_type",
            "ticket_id",
            "contact_id",
            "user_id",
            "attachments",
            "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
