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_employee_census import TypesEmployeeCensus
    from ..models.types_employee_census_issue import TypesEmployeeCensusIssue


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


@_attrs_define
class PkgRoutesPackagesRetirementCensusRecalculateCensusResponse:
    """
    Attributes:
        employee_census (list[TypesEmployeeCensus] | Unset):
        issues (list[TypesEmployeeCensusIssue] | Unset):
        ok (bool | Unset):
    """

    employee_census: list[TypesEmployeeCensus] | Unset = UNSET
    issues: list[TypesEmployeeCensusIssue] | Unset = UNSET
    ok: bool | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        employee_census: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.employee_census, Unset):
            employee_census = []
            for employee_census_item_data in self.employee_census:
                employee_census_item = employee_census_item_data.to_dict()
                employee_census.append(employee_census_item)

        issues: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.issues, Unset):
            issues = []
            for issues_item_data in self.issues:
                issues_item = issues_item_data.to_dict()
                issues.append(issues_item)

        ok = self.ok

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if employee_census is not UNSET:
            field_dict["employeeCensus"] = employee_census
        if issues is not UNSET:
            field_dict["issues"] = issues
        if ok is not UNSET:
            field_dict["ok"] = ok

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_employee_census import TypesEmployeeCensus
        from ..models.types_employee_census_issue import TypesEmployeeCensusIssue

        d = dict(src_dict)
        _employee_census = d.pop("employeeCensus", UNSET)
        employee_census: list[TypesEmployeeCensus] | Unset = UNSET
        if _employee_census is not UNSET:
            employee_census = []
            for employee_census_item_data in _employee_census:
                employee_census_item = TypesEmployeeCensus.from_dict(employee_census_item_data)

                employee_census.append(employee_census_item)

        _issues = d.pop("issues", UNSET)
        issues: list[TypesEmployeeCensusIssue] | Unset = UNSET
        if _issues is not UNSET:
            issues = []
            for issues_item_data in _issues:
                issues_item = TypesEmployeeCensusIssue.from_dict(issues_item_data)

                issues.append(issues_item)

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

        pkg_routes_packages_retirement_census_recalculate_census_response = cls(
            employee_census=employee_census,
            issues=issues,
            ok=ok,
        )

        pkg_routes_packages_retirement_census_recalculate_census_response.additional_properties = d
        return pkg_routes_packages_retirement_census_recalculate_census_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
