from __future__ import annotations

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

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_suggested_task import TypesSuggestedTask


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


@_attrs_define
class TypesEmailSummary:
    """
    Attributes:
        client (str | Unset):
        message (str | Unset):
        priority (int | Unset):
        suggested_tasks (list[TypesSuggestedTask] | Unset):
        summary (str | Unset):
        thread (str | Unset):
    """

    client: str | Unset = UNSET
    message: str | Unset = UNSET
    priority: int | Unset = UNSET
    suggested_tasks: list[TypesSuggestedTask] | Unset = UNSET
    summary: str | Unset = UNSET
    thread: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        message = self.message

        priority = self.priority

        suggested_tasks: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.suggested_tasks, Unset):
            suggested_tasks = []
            for suggested_tasks_item_data in self.suggested_tasks:
                suggested_tasks_item = suggested_tasks_item_data.to_dict()
                suggested_tasks.append(suggested_tasks_item)

        summary = self.summary

        thread = self.thread

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if client is not UNSET:
            field_dict["client"] = client
        if message is not UNSET:
            field_dict["message"] = message
        if priority is not UNSET:
            field_dict["priority"] = priority
        if suggested_tasks is not UNSET:
            field_dict["suggested_tasks"] = suggested_tasks
        if summary is not UNSET:
            field_dict["summary"] = summary
        if thread is not UNSET:
            field_dict["thread"] = thread

        return field_dict

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

        d = dict(src_dict)
        client = d.pop("client", UNSET)

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

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

        _suggested_tasks = d.pop("suggested_tasks", UNSET)
        suggested_tasks: list[TypesSuggestedTask] | Unset = UNSET
        if _suggested_tasks is not UNSET:
            suggested_tasks = []
            for suggested_tasks_item_data in _suggested_tasks:
                suggested_tasks_item = TypesSuggestedTask.from_dict(suggested_tasks_item_data)

                suggested_tasks.append(suggested_tasks_item)

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

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

        types_email_summary = cls(
            client=client,
            message=message,
            priority=priority,
            suggested_tasks=suggested_tasks,
            summary=summary,
            thread=thread,
        )

        types_email_summary.additional_properties = d
        return types_email_summary

    @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
