from __future__ import annotations

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

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

from ..types import UNSET, Unset

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


@_attrs_define
class TypesWarning:
    """
    Attributes:
        dismiss (bool | Unset):
        fields (list[str] | Unset): Which fields have triggered this warning
        money_type (str | Unset): Track by money type
        reason (str | Unset):
    """

    dismiss: bool | Unset = UNSET
    fields: list[str] | Unset = UNSET
    money_type: str | Unset = UNSET
    reason: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

        money_type = self.money_type

        reason = self.reason

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if dismiss is not UNSET:
            field_dict["dismiss"] = dismiss
        if fields is not UNSET:
            field_dict["fields"] = fields
        if money_type is not UNSET:
            field_dict["money_type"] = money_type
        if reason is not UNSET:
            field_dict["reason"] = reason

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        dismiss = d.pop("dismiss", UNSET)

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

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

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

        types_warning = cls(
            dismiss=dismiss,
            fields=fields,
            money_type=money_type,
            reason=reason,
        )

        types_warning.additional_properties = d
        return types_warning

    @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
