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="TypesShortEmployeeCensusError")


@_attrs_define
class TypesShortEmployeeCensusError:
    """
    Attributes:
        custom (str | Unset): Set to nil if this is not a custom issue, otherwise set to a random ID for tracking
        detail (str | Unset):
        field_names (list[str] | Unset):
        path (list[str] | Unset):
        plan (str | Unset):
        reason (str | Unset):
        reviewed (bool | Unset):
    """

    custom: str | Unset = UNSET
    detail: str | Unset = UNSET
    field_names: list[str] | Unset = UNSET
    path: list[str] | Unset = UNSET
    plan: str | Unset = UNSET
    reason: str | Unset = UNSET
    reviewed: bool | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        detail = self.detail

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

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

        plan = self.plan

        reason = self.reason

        reviewed = self.reviewed

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if custom is not UNSET:
            field_dict["custom"] = custom
        if detail is not UNSET:
            field_dict["detail"] = detail
        if field_names is not UNSET:
            field_dict["field_names"] = field_names
        if path is not UNSET:
            field_dict["path"] = path
        if plan is not UNSET:
            field_dict["plan"] = plan
        if reason is not UNSET:
            field_dict["reason"] = reason
        if reviewed is not UNSET:
            field_dict["reviewed"] = reviewed

        return field_dict

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

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

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

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

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

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

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

        types_short_employee_census_error = cls(
            custom=custom,
            detail=detail,
            field_names=field_names,
            path=path,
            plan=plan,
            reason=reason,
            reviewed=reviewed,
        )

        types_short_employee_census_error.additional_properties = d
        return types_short_employee_census_error

    @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
