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.pkg_routes_packages_retirement_participants_participant_client_plan import (
        PkgRoutesPackagesRetirementParticipantsParticipantClientPlan,
    )
    from ..models.types_payroll_config import TypesPayrollConfig


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


@_attrs_define
class PkgRoutesPackagesRetirementParticipantsParticipantClient:
    """
    Attributes:
        field_id (str | Unset): client._id
        employees (int | Unset):
        errors (int | Unset):
        name (str | Unset):
        payroll (TypesPayrollConfig | Unset):
        plans (list[PkgRoutesPackagesRetirementParticipantsParticipantClientPlan] | Unset):
        status (str | Unset):
        tags (list[str] | Unset):
    """

    field_id: str | Unset = UNSET
    employees: int | Unset = UNSET
    errors: int | Unset = UNSET
    name: str | Unset = UNSET
    payroll: TypesPayrollConfig | Unset = UNSET
    plans: list[PkgRoutesPackagesRetirementParticipantsParticipantClientPlan] | Unset = UNSET
    status: str | Unset = UNSET
    tags: list[str] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        employees = self.employees

        errors = self.errors

        name = self.name

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

        plans: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.plans, Unset):
            plans = []
            for plans_item_data in self.plans:
                plans_item = plans_item_data.to_dict()
                plans.append(plans_item)

        status = self.status

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

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if field_id is not UNSET:
            field_dict["_id"] = field_id
        if employees is not UNSET:
            field_dict["employees"] = employees
        if errors is not UNSET:
            field_dict["errors"] = errors
        if name is not UNSET:
            field_dict["name"] = name
        if payroll is not UNSET:
            field_dict["payroll"] = payroll
        if plans is not UNSET:
            field_dict["plans"] = plans
        if status is not UNSET:
            field_dict["status"] = status
        if tags is not UNSET:
            field_dict["tags"] = tags

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.pkg_routes_packages_retirement_participants_participant_client_plan import (
            PkgRoutesPackagesRetirementParticipantsParticipantClientPlan,
        )
        from ..models.types_payroll_config import TypesPayrollConfig

        d = dict(src_dict)
        field_id = d.pop("_id", UNSET)

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

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

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

        _payroll = d.pop("payroll", UNSET)
        payroll: TypesPayrollConfig | Unset
        if isinstance(_payroll, Unset):
            payroll = UNSET
        else:
            payroll = TypesPayrollConfig.from_dict(_payroll)

        _plans = d.pop("plans", UNSET)
        plans: list[PkgRoutesPackagesRetirementParticipantsParticipantClientPlan] | Unset = UNSET
        if _plans is not UNSET:
            plans = []
            for plans_item_data in _plans:
                plans_item = PkgRoutesPackagesRetirementParticipantsParticipantClientPlan.from_dict(plans_item_data)

                plans.append(plans_item)

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

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

        pkg_routes_packages_retirement_participants_participant_client = cls(
            field_id=field_id,
            employees=employees,
            errors=errors,
            name=name,
            payroll=payroll,
            plans=plans,
            status=status,
            tags=tags,
        )

        pkg_routes_packages_retirement_participants_participant_client.additional_properties = d
        return pkg_routes_packages_retirement_participants_participant_client

    @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
