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


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


@_attrs_define
class PkgRoutesCpContactsLookupContactResponse:
    """
    Attributes:
        client_count (int | Unset):
        contact (TypesContact | Unset):
        exists (bool | Unset):
        used_by_others (bool | Unset):
    """

    client_count: int | Unset = UNSET
    contact: TypesContact | Unset = UNSET
    exists: bool | Unset = UNSET
    used_by_others: bool | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

        exists = self.exists

        used_by_others = self.used_by_others

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if client_count is not UNSET:
            field_dict["clientCount"] = client_count
        if contact is not UNSET:
            field_dict["contact"] = contact
        if exists is not UNSET:
            field_dict["exists"] = exists
        if used_by_others is not UNSET:
            field_dict["usedByOthers"] = used_by_others

        return field_dict

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

        d = dict(src_dict)
        client_count = d.pop("clientCount", UNSET)

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

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

        used_by_others = d.pop("usedByOthers", UNSET)

        pkg_routes_cp_contacts_lookup_contact_response = cls(
            client_count=client_count,
            contact=contact,
            exists=exists,
            used_by_others=used_by_others,
        )

        pkg_routes_cp_contacts_lookup_contact_response.additional_properties = d
        return pkg_routes_cp_contacts_lookup_contact_response

    @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
