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_email_summary import TypesEmailSummary


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


@_attrs_define
class TypesDailyBriefing:
    """
    Attributes:
        field_id (str | Unset):
        date (str | Unset):
        generated_at (str | Unset):
        summary (list[TypesEmailSummary] | Unset):
        team (str | Unset):
        user (str | Unset):
    """

    field_id: str | Unset = UNSET
    date: str | Unset = UNSET
    generated_at: str | Unset = UNSET
    summary: list[TypesEmailSummary] | Unset = UNSET
    team: 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

        date = self.date

        generated_at = self.generated_at

        summary: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.summary, Unset):
            summary = []
            for summary_item_data in self.summary:
                summary_item = summary_item_data.to_dict()
                summary.append(summary_item)

        team = self.team

        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 date is not UNSET:
            field_dict["date"] = date
        if generated_at is not UNSET:
            field_dict["generated_at"] = generated_at
        if summary is not UNSET:
            field_dict["summary"] = summary
        if team is not UNSET:
            field_dict["team"] = team
        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_email_summary import TypesEmailSummary

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

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

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

        _summary = d.pop("summary", UNSET)
        summary: list[TypesEmailSummary] | Unset = UNSET
        if _summary is not UNSET:
            summary = []
            for summary_item_data in _summary:
                summary_item = TypesEmailSummary.from_dict(summary_item_data)

                summary.append(summary_item)

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

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

        types_daily_briefing = cls(
            field_id=field_id,
            date=date,
            generated_at=generated_at,
            summary=summary,
            team=team,
            user=user,
        )

        types_daily_briefing.additional_properties = d
        return types_daily_briefing

    @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
