from __future__ import annotations

from collections.abc import Mapping
from typing import TYPE_CHECKING, Any, TypeVar, cast

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.types_attachment import TypesAttachment


T = TypeVar("T", bound="TypesMessage")


@_attrs_define
class TypesMessage:
    """
    Attributes:
        field_id (str | Unset):
        attachments (list[TypesAttachment] | Unset):
        bcc (str | Unset):
        bookmark (bool | Unset):
        brief (str | Unset): Single-line summary
        cc (str | Unset):
        checksum (str | Unset): Checksum for de-duplication
        clients (list[str] | Unset): Is this message to/from a client?
        created_at (str | Unset):
        date (str | Unset):
        deleted_at (str | Unset):
        domains (list[str] | Unset):
        draft (bool | Unset):
        from_ (str | Unset):
        html (str | Unset):
        importance (int | Unset):
        in_reply_to (str | Unset):
        internal (bool | Unset): Is this message to/from only internal users?
        outbox (bool | Unset): Magical stuff
        private (bool | Unset): The private flag is used if the message is from/to only internal admins (regardless of
            how many external users) that have the memberships.email.private flag set.
            This prevents other users from seeing external messages that may be private.
        read (str | Unset):
        references (str | Unset):
        reply (str | Unset):
        requires_response (bool | Unset):
        responses (list[str] | Unset):
        safe_for_everyone (bool | Unset):
        schedule_send_at (str | Unset): Schedule sending this at a specific time
        secure (bool | Unset):
        send_scheduled (bool | Unset):
        sentiment (int | Unset):
        source (str | Unset):
        source_history_id (str | Unset):
        source_id (str | Unset):
        subject (str | Unset):
        summary (list[str] | Unset):
        tags (list[str] | Unset):
        tasks (list[str] | Unset):
        team (str | Unset):
        text (str | Unset):
        thread (str | Unset):
        to (str | Unset):
        unique_key (str | Unset):
        user (str | Unset):
    """

    field_id: str | Unset = UNSET
    attachments: list[TypesAttachment] | Unset = UNSET
    bcc: str | Unset = UNSET
    bookmark: bool | Unset = UNSET
    brief: str | Unset = UNSET
    cc: str | Unset = UNSET
    checksum: str | Unset = UNSET
    clients: list[str] | Unset = UNSET
    created_at: str | Unset = UNSET
    date: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    domains: list[str] | Unset = UNSET
    draft: bool | Unset = UNSET
    from_: str | Unset = UNSET
    html: str | Unset = UNSET
    importance: int | Unset = UNSET
    in_reply_to: str | Unset = UNSET
    internal: bool | Unset = UNSET
    outbox: bool | Unset = UNSET
    private: bool | Unset = UNSET
    read: str | Unset = UNSET
    references: str | Unset = UNSET
    reply: str | Unset = UNSET
    requires_response: bool | Unset = UNSET
    responses: list[str] | Unset = UNSET
    safe_for_everyone: bool | Unset = UNSET
    schedule_send_at: str | Unset = UNSET
    secure: bool | Unset = UNSET
    send_scheduled: bool | Unset = UNSET
    sentiment: int | Unset = UNSET
    source: str | Unset = UNSET
    source_history_id: str | Unset = UNSET
    source_id: str | Unset = UNSET
    subject: str | Unset = UNSET
    summary: list[str] | Unset = UNSET
    tags: list[str] | Unset = UNSET
    tasks: list[str] | Unset = UNSET
    team: str | Unset = UNSET
    text: str | Unset = UNSET
    thread: str | Unset = UNSET
    to: str | Unset = UNSET
    unique_key: str | Unset = UNSET
    user: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        field_id = self.field_id

        attachments: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.attachments, Unset):
            attachments = []
            for attachments_item_data in self.attachments:
                attachments_item = attachments_item_data.to_dict()
                attachments.append(attachments_item)

        bcc = self.bcc

        bookmark = self.bookmark

        brief = self.brief

        cc = self.cc

        checksum = self.checksum

        clients: list[str] | Unset = UNSET
        if not isinstance(self.clients, Unset):
            clients = self.clients

        created_at = self.created_at

        date = self.date

        deleted_at = self.deleted_at

        domains: list[str] | Unset = UNSET
        if not isinstance(self.domains, Unset):
            domains = self.domains

        draft = self.draft

        from_ = self.from_

        html = self.html

        importance = self.importance

        in_reply_to = self.in_reply_to

        internal = self.internal

        outbox = self.outbox

        private = self.private

        read = self.read

        references = self.references

        reply = self.reply

        requires_response = self.requires_response

        responses: list[str] | Unset = UNSET
        if not isinstance(self.responses, Unset):
            responses = self.responses

        safe_for_everyone = self.safe_for_everyone

        schedule_send_at = self.schedule_send_at

        secure = self.secure

        send_scheduled = self.send_scheduled

        sentiment = self.sentiment

        source = self.source

        source_history_id = self.source_history_id

        source_id = self.source_id

        subject = self.subject

        summary: list[str] | Unset = UNSET
        if not isinstance(self.summary, Unset):
            summary = self.summary

        tags: list[str] | Unset = UNSET
        if not isinstance(self.tags, Unset):
            tags = self.tags

        tasks: list[str] | Unset = UNSET
        if not isinstance(self.tasks, Unset):
            tasks = self.tasks

        team = self.team

        text = self.text

        thread = self.thread

        to = self.to

        unique_key = self.unique_key

        user = self.user

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if field_id is not UNSET:
            field_dict["_id"] = field_id
        if attachments is not UNSET:
            field_dict["attachments"] = attachments
        if bcc is not UNSET:
            field_dict["bcc"] = bcc
        if bookmark is not UNSET:
            field_dict["bookmark"] = bookmark
        if brief is not UNSET:
            field_dict["brief"] = brief
        if cc is not UNSET:
            field_dict["cc"] = cc
        if checksum is not UNSET:
            field_dict["checksum"] = checksum
        if clients is not UNSET:
            field_dict["clients"] = clients
        if created_at is not UNSET:
            field_dict["created_at"] = created_at
        if date is not UNSET:
            field_dict["date"] = date
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if domains is not UNSET:
            field_dict["domains"] = domains
        if draft is not UNSET:
            field_dict["draft"] = draft
        if from_ is not UNSET:
            field_dict["from"] = from_
        if html is not UNSET:
            field_dict["html"] = html
        if importance is not UNSET:
            field_dict["importance"] = importance
        if in_reply_to is not UNSET:
            field_dict["in_reply_to"] = in_reply_to
        if internal is not UNSET:
            field_dict["internal"] = internal
        if outbox is not UNSET:
            field_dict["outbox"] = outbox
        if private is not UNSET:
            field_dict["private"] = private
        if read is not UNSET:
            field_dict["read"] = read
        if references is not UNSET:
            field_dict["references"] = references
        if reply is not UNSET:
            field_dict["reply"] = reply
        if requires_response is not UNSET:
            field_dict["requires_response"] = requires_response
        if responses is not UNSET:
            field_dict["responses"] = responses
        if safe_for_everyone is not UNSET:
            field_dict["safe_for_everyone"] = safe_for_everyone
        if schedule_send_at is not UNSET:
            field_dict["schedule_send_at"] = schedule_send_at
        if secure is not UNSET:
            field_dict["secure"] = secure
        if send_scheduled is not UNSET:
            field_dict["send_scheduled"] = send_scheduled
        if sentiment is not UNSET:
            field_dict["sentiment"] = sentiment
        if source is not UNSET:
            field_dict["source"] = source
        if source_history_id is not UNSET:
            field_dict["source_history_id"] = source_history_id
        if source_id is not UNSET:
            field_dict["source_id"] = source_id
        if subject is not UNSET:
            field_dict["subject"] = subject
        if summary is not UNSET:
            field_dict["summary"] = summary
        if tags is not UNSET:
            field_dict["tags"] = tags
        if tasks is not UNSET:
            field_dict["tasks"] = tasks
        if team is not UNSET:
            field_dict["team"] = team
        if text is not UNSET:
            field_dict["text"] = text
        if thread is not UNSET:
            field_dict["thread"] = thread
        if to is not UNSET:
            field_dict["to"] = to
        if unique_key is not UNSET:
            field_dict["unique_key"] = unique_key
        if user is not UNSET:
            field_dict["user"] = user

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_attachment import TypesAttachment

        d = dict(src_dict)
        field_id = d.pop("_id", UNSET)

        _attachments = d.pop("attachments", UNSET)
        attachments: list[TypesAttachment] | Unset = UNSET
        if _attachments is not UNSET:
            attachments = []
            for attachments_item_data in _attachments:
                attachments_item = TypesAttachment.from_dict(attachments_item_data)

                attachments.append(attachments_item)

        bcc = d.pop("bcc", UNSET)

        bookmark = d.pop("bookmark", UNSET)

        brief = d.pop("brief", UNSET)

        cc = d.pop("cc", UNSET)

        checksum = d.pop("checksum", UNSET)

        clients = cast(list[str], d.pop("clients", UNSET))

        created_at = d.pop("created_at", UNSET)

        date = d.pop("date", UNSET)

        deleted_at = d.pop("deleted_at", UNSET)

        domains = cast(list[str], d.pop("domains", UNSET))

        draft = d.pop("draft", UNSET)

        from_ = d.pop("from", UNSET)

        html = d.pop("html", UNSET)

        importance = d.pop("importance", UNSET)

        in_reply_to = d.pop("in_reply_to", UNSET)

        internal = d.pop("internal", UNSET)

        outbox = d.pop("outbox", UNSET)

        private = d.pop("private", UNSET)

        read = d.pop("read", UNSET)

        references = d.pop("references", UNSET)

        reply = d.pop("reply", UNSET)

        requires_response = d.pop("requires_response", UNSET)

        responses = cast(list[str], d.pop("responses", UNSET))

        safe_for_everyone = d.pop("safe_for_everyone", UNSET)

        schedule_send_at = d.pop("schedule_send_at", UNSET)

        secure = d.pop("secure", UNSET)

        send_scheduled = d.pop("send_scheduled", UNSET)

        sentiment = d.pop("sentiment", UNSET)

        source = d.pop("source", UNSET)

        source_history_id = d.pop("source_history_id", UNSET)

        source_id = d.pop("source_id", UNSET)

        subject = d.pop("subject", UNSET)

        summary = cast(list[str], d.pop("summary", UNSET))

        tags = cast(list[str], d.pop("tags", UNSET))

        tasks = cast(list[str], d.pop("tasks", UNSET))

        team = d.pop("team", UNSET)

        text = d.pop("text", UNSET)

        thread = d.pop("thread", UNSET)

        to = d.pop("to", UNSET)

        unique_key = d.pop("unique_key", UNSET)

        user = d.pop("user", UNSET)

        types_message = cls(
            field_id=field_id,
            attachments=attachments,
            bcc=bcc,
            bookmark=bookmark,
            brief=brief,
            cc=cc,
            checksum=checksum,
            clients=clients,
            created_at=created_at,
            date=date,
            deleted_at=deleted_at,
            domains=domains,
            draft=draft,
            from_=from_,
            html=html,
            importance=importance,
            in_reply_to=in_reply_to,
            internal=internal,
            outbox=outbox,
            private=private,
            read=read,
            references=references,
            reply=reply,
            requires_response=requires_response,
            responses=responses,
            safe_for_everyone=safe_for_everyone,
            schedule_send_at=schedule_send_at,
            secure=secure,
            send_scheduled=send_scheduled,
            sentiment=sentiment,
            source=source,
            source_history_id=source_history_id,
            source_id=source_id,
            subject=subject,
            summary=summary,
            tags=tags,
            tasks=tasks,
            team=team,
            text=text,
            thread=thread,
            to=to,
            unique_key=unique_key,
            user=user,
        )

        types_message.additional_properties = d
        return types_message

    @property
    def additional_keys(self) -> list[str]:
        return list(self.additional_properties.keys())

    def __getitem__(self, key: str) -> Any:
        return self.additional_properties[key]

    def __setitem__(self, key: str, value: Any) -> None:
        self.additional_properties[key] = value

    def __delitem__(self, key: str) -> None:
        del self.additional_properties[key]

    def __contains__(self, key: str) -> bool:
        return key in self.additional_properties
