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_contact import TypesContact
    from ..models.types_invitation import TypesInvitation
    from ..models.types_user import TypesUser


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


@_attrs_define
class TypesClientContact:
    """
    Attributes:
        contact (TypesContact | Unset):
        deal (str | Unset):
        ignore_emails (bool | Unset):
        inactive (bool | Unset):
        invite (TypesInvitation | Unset):
        plan (str | Unset): Are the contacts specifically tied to a plan or deal?
        role (str | Unset):
        shared (bool | Unset):
        user (TypesUser | Unset):
    """

    contact: TypesContact | Unset = UNSET
    deal: str | Unset = UNSET
    ignore_emails: bool | Unset = UNSET
    inactive: bool | Unset = UNSET
    invite: TypesInvitation | Unset = UNSET
    plan: str | Unset = UNSET
    role: str | Unset = UNSET
    shared: bool | Unset = UNSET
    user: TypesUser | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        contact: dict[str, Any] | Unset = UNSET
        if not isinstance(self.contact, Unset):
            contact = self.contact.to_dict()

        deal = self.deal

        ignore_emails = self.ignore_emails

        inactive = self.inactive

        invite: dict[str, Any] | Unset = UNSET
        if not isinstance(self.invite, Unset):
            invite = self.invite.to_dict()

        plan = self.plan

        role = self.role

        shared = self.shared

        user: dict[str, Any] | Unset = UNSET
        if not isinstance(self.user, Unset):
            user = self.user.to_dict()

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if contact is not UNSET:
            field_dict["contact"] = contact
        if deal is not UNSET:
            field_dict["deal"] = deal
        if ignore_emails is not UNSET:
            field_dict["ignore_emails"] = ignore_emails
        if inactive is not UNSET:
            field_dict["inactive"] = inactive
        if invite is not UNSET:
            field_dict["invite"] = invite
        if plan is not UNSET:
            field_dict["plan"] = plan
        if role is not UNSET:
            field_dict["role"] = role
        if shared is not UNSET:
            field_dict["shared"] = shared
        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_contact import TypesContact
        from ..models.types_invitation import TypesInvitation
        from ..models.types_user import TypesUser

        d = dict(src_dict)
        _contact = d.pop("contact", UNSET)
        contact: TypesContact | Unset
        if isinstance(_contact, Unset):
            contact = UNSET
        else:
            contact = TypesContact.from_dict(_contact)

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

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

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

        _invite = d.pop("invite", UNSET)
        invite: TypesInvitation | Unset
        if isinstance(_invite, Unset):
            invite = UNSET
        else:
            invite = TypesInvitation.from_dict(_invite)

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

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

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

        _user = d.pop("user", UNSET)
        user: TypesUser | Unset
        if isinstance(_user, Unset):
            user = UNSET
        else:
            user = TypesUser.from_dict(_user)

        types_client_contact = cls(
            contact=contact,
            deal=deal,
            ignore_emails=ignore_emails,
            inactive=inactive,
            invite=invite,
            plan=plan,
            role=role,
            shared=shared,
            user=user,
        )

        types_client_contact.additional_properties = d
        return types_client_contact

    @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
