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.legacytypes_collaborator import LegacytypesCollaborator
    from ..models.legacytypes_contact import LegacytypesContact


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


@_attrs_define
class LegacytypesExternalContact:
    """
    Attributes:
        collaborator (LegacytypesCollaborator | Unset):
        contact (LegacytypesContact | Unset):
        deal (str | Unset):
        hide_from_client (bool | Unset):
        inactive (bool | Unset):
        plan (str | Unset): Are the contacts specifically tied to a plan or deal?
        role (str | Unset):
        shared (bool | Unset): For returning
    """

    collaborator: LegacytypesCollaborator | Unset = UNSET
    contact: LegacytypesContact | Unset = UNSET
    deal: str | Unset = UNSET
    hide_from_client: bool | Unset = UNSET
    inactive: bool | Unset = UNSET
    plan: str | Unset = UNSET
    role: str | Unset = UNSET
    shared: bool | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

        deal = self.deal

        hide_from_client = self.hide_from_client

        inactive = self.inactive

        plan = self.plan

        role = self.role

        shared = self.shared

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if collaborator is not UNSET:
            field_dict["collaborator"] = collaborator
        if contact is not UNSET:
            field_dict["contact"] = contact
        if deal is not UNSET:
            field_dict["deal"] = deal
        if hide_from_client is not UNSET:
            field_dict["hide_from_client"] = hide_from_client
        if inactive is not UNSET:
            field_dict["inactive"] = inactive
        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

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.legacytypes_collaborator import LegacytypesCollaborator
        from ..models.legacytypes_contact import LegacytypesContact

        d = dict(src_dict)
        _collaborator = d.pop("collaborator", UNSET)
        collaborator: LegacytypesCollaborator | Unset
        if isinstance(_collaborator, Unset):
            collaborator = UNSET
        else:
            collaborator = LegacytypesCollaborator.from_dict(_collaborator)

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

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

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

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

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

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

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

        legacytypes_external_contact = cls(
            collaborator=collaborator,
            contact=contact,
            deal=deal,
            hide_from_client=hide_from_client,
            inactive=inactive,
            plan=plan,
            role=role,
            shared=shared,
        )

        legacytypes_external_contact.additional_properties = d
        return legacytypes_external_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
