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_efast_creds import LegacytypesEfastCreds


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


@_attrs_define
class LegacytypesEfast:
    """
    Attributes:
        admin (LegacytypesEfastCreds | Unset):
        dfe (LegacytypesEfastCreds | Unset):
        electronic (LegacytypesEfastCreds | Unset):
        sponsor (LegacytypesEfastCreds | Unset):
    """

    admin: LegacytypesEfastCreds | Unset = UNSET
    dfe: LegacytypesEfastCreds | Unset = UNSET
    electronic: LegacytypesEfastCreds | Unset = UNSET
    sponsor: LegacytypesEfastCreds | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

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

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

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if admin is not UNSET:
            field_dict["admin"] = admin
        if dfe is not UNSET:
            field_dict["dfe"] = dfe
        if electronic is not UNSET:
            field_dict["electronic"] = electronic
        if sponsor is not UNSET:
            field_dict["sponsor"] = sponsor

        return field_dict

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

        d = dict(src_dict)
        _admin = d.pop("admin", UNSET)
        admin: LegacytypesEfastCreds | Unset
        if isinstance(_admin, Unset):
            admin = UNSET
        else:
            admin = LegacytypesEfastCreds.from_dict(_admin)

        _dfe = d.pop("dfe", UNSET)
        dfe: LegacytypesEfastCreds | Unset
        if isinstance(_dfe, Unset):
            dfe = UNSET
        else:
            dfe = LegacytypesEfastCreds.from_dict(_dfe)

        _electronic = d.pop("electronic", UNSET)
        electronic: LegacytypesEfastCreds | Unset
        if isinstance(_electronic, Unset):
            electronic = UNSET
        else:
            electronic = LegacytypesEfastCreds.from_dict(_electronic)

        _sponsor = d.pop("sponsor", UNSET)
        sponsor: LegacytypesEfastCreds | Unset
        if isinstance(_sponsor, Unset):
            sponsor = UNSET
        else:
            sponsor = LegacytypesEfastCreds.from_dict(_sponsor)

        legacytypes_efast = cls(
            admin=admin,
            dfe=dfe,
            electronic=electronic,
            sponsor=sponsor,
        )

        legacytypes_efast.additional_properties = d
        return legacytypes_efast

    @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
