from __future__ import annotations

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

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

if TYPE_CHECKING:
    from ..models.fax_service import FaxService


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


@_attrs_define
class FaxConfig:
    """
    Attributes:
        enable_inbound (bool | Unset):
        enable_outbound (bool | Unset):
        numbers (list[str] | Unset):
        n_received (float | Unset):
        n_sent (float | Unset):
        service (FaxService | Unset):
    """

    enable_inbound: bool | Unset = UNSET
    enable_outbound: bool | Unset = UNSET
    numbers: list[str] | Unset = UNSET
    n_received: float | Unset = UNSET
    n_sent: float | Unset = UNSET
    service: FaxService | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        enable_outbound = self.enable_outbound

        numbers: list[str] | Unset = UNSET
        if not isinstance(self.numbers, Unset):
            numbers = self.numbers

        n_received = self.n_received

        n_sent = self.n_sent

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

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if enable_inbound is not UNSET:
            field_dict["enableInbound"] = enable_inbound
        if enable_outbound is not UNSET:
            field_dict["enableOutbound"] = enable_outbound
        if numbers is not UNSET:
            field_dict["numbers"] = numbers
        if n_received is not UNSET:
            field_dict["nReceived"] = n_received
        if n_sent is not UNSET:
            field_dict["nSent"] = n_sent
        if service is not UNSET:
            field_dict["service"] = service

        return field_dict

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

        d = dict(src_dict)
        enable_inbound = d.pop("enableInbound", UNSET)

        enable_outbound = d.pop("enableOutbound", UNSET)

        numbers = cast(list[str], d.pop("numbers", UNSET))

        n_received = d.pop("nReceived", UNSET)

        n_sent = d.pop("nSent", UNSET)

        _service = d.pop("service", UNSET)
        service: FaxService | Unset
        if isinstance(_service, Unset):
            service = UNSET
        else:
            service = FaxService.from_dict(_service)

        fax_config = cls(
            enable_inbound=enable_inbound,
            enable_outbound=enable_outbound,
            numbers=numbers,
            n_received=n_received,
            n_sent=n_sent,
            service=service,
        )

        fax_config.additional_properties = d
        return fax_config

    @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
