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_exclusions import TypesExclusions
    from ..models.types_money_type_strings import TypesMoneyTypeStrings
    from ..models.types_plan_compensation import TypesPlanCompensation
    from ..models.types_plan_dates import TypesPlanDates
    from ..models.types_transactions import TypesTransactions
    from ..models.types_vesting import TypesVesting
    from ..models.types_warning import TypesWarning


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


@_attrs_define
class TypesPlanData:
    """
    Attributes:
        eligibility_date (TypesPlanDates | Unset):
        eligibility_reason (TypesMoneyTypeStrings | Unset):
        eligibility_status (TypesMoneyTypeStrings | Unset):
        eligible_gross_pay (TypesPlanCompensation | Unset):
        entry_date (TypesPlanDates | Unset):
        exclusions (TypesExclusions | Unset):
        plan_compensation (TypesPlanCompensation | Unset):
        plan_id (str | Unset):
        plan_type (str | Unset):
        transactions (TypesTransactions | Unset):
        vesting (TypesVesting | Unset):
        warnings (list[TypesWarning] | Unset):
    """

    eligibility_date: TypesPlanDates | Unset = UNSET
    eligibility_reason: TypesMoneyTypeStrings | Unset = UNSET
    eligibility_status: TypesMoneyTypeStrings | Unset = UNSET
    eligible_gross_pay: TypesPlanCompensation | Unset = UNSET
    entry_date: TypesPlanDates | Unset = UNSET
    exclusions: TypesExclusions | Unset = UNSET
    plan_compensation: TypesPlanCompensation | Unset = UNSET
    plan_id: str | Unset = UNSET
    plan_type: str | Unset = UNSET
    transactions: TypesTransactions | Unset = UNSET
    vesting: TypesVesting | Unset = UNSET
    warnings: list[TypesWarning] | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

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

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

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

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

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

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

        plan_id = self.plan_id

        plan_type = self.plan_type

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

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

        warnings: list[dict[str, Any]] | Unset = UNSET
        if not isinstance(self.warnings, Unset):
            warnings = []
            for warnings_item_data in self.warnings:
                warnings_item = warnings_item_data.to_dict()
                warnings.append(warnings_item)

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if eligibility_date is not UNSET:
            field_dict["eligibility_date"] = eligibility_date
        if eligibility_reason is not UNSET:
            field_dict["eligibility_reason"] = eligibility_reason
        if eligibility_status is not UNSET:
            field_dict["eligibility_status"] = eligibility_status
        if eligible_gross_pay is not UNSET:
            field_dict["eligible_gross_pay"] = eligible_gross_pay
        if entry_date is not UNSET:
            field_dict["entry_date"] = entry_date
        if exclusions is not UNSET:
            field_dict["exclusions"] = exclusions
        if plan_compensation is not UNSET:
            field_dict["plan_compensation"] = plan_compensation
        if plan_id is not UNSET:
            field_dict["plan_id"] = plan_id
        if plan_type is not UNSET:
            field_dict["plan_type"] = plan_type
        if transactions is not UNSET:
            field_dict["transactions"] = transactions
        if vesting is not UNSET:
            field_dict["vesting"] = vesting
        if warnings is not UNSET:
            field_dict["warnings"] = warnings

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.types_exclusions import TypesExclusions
        from ..models.types_money_type_strings import TypesMoneyTypeStrings
        from ..models.types_plan_compensation import TypesPlanCompensation
        from ..models.types_plan_dates import TypesPlanDates
        from ..models.types_transactions import TypesTransactions
        from ..models.types_vesting import TypesVesting
        from ..models.types_warning import TypesWarning

        d = dict(src_dict)
        _eligibility_date = d.pop("eligibility_date", UNSET)
        eligibility_date: TypesPlanDates | Unset
        if isinstance(_eligibility_date, Unset):
            eligibility_date = UNSET
        else:
            eligibility_date = TypesPlanDates.from_dict(_eligibility_date)

        _eligibility_reason = d.pop("eligibility_reason", UNSET)
        eligibility_reason: TypesMoneyTypeStrings | Unset
        if isinstance(_eligibility_reason, Unset):
            eligibility_reason = UNSET
        else:
            eligibility_reason = TypesMoneyTypeStrings.from_dict(_eligibility_reason)

        _eligibility_status = d.pop("eligibility_status", UNSET)
        eligibility_status: TypesMoneyTypeStrings | Unset
        if isinstance(_eligibility_status, Unset):
            eligibility_status = UNSET
        else:
            eligibility_status = TypesMoneyTypeStrings.from_dict(_eligibility_status)

        _eligible_gross_pay = d.pop("eligible_gross_pay", UNSET)
        eligible_gross_pay: TypesPlanCompensation | Unset
        if isinstance(_eligible_gross_pay, Unset):
            eligible_gross_pay = UNSET
        else:
            eligible_gross_pay = TypesPlanCompensation.from_dict(_eligible_gross_pay)

        _entry_date = d.pop("entry_date", UNSET)
        entry_date: TypesPlanDates | Unset
        if isinstance(_entry_date, Unset):
            entry_date = UNSET
        else:
            entry_date = TypesPlanDates.from_dict(_entry_date)

        _exclusions = d.pop("exclusions", UNSET)
        exclusions: TypesExclusions | Unset
        if isinstance(_exclusions, Unset):
            exclusions = UNSET
        else:
            exclusions = TypesExclusions.from_dict(_exclusions)

        _plan_compensation = d.pop("plan_compensation", UNSET)
        plan_compensation: TypesPlanCompensation | Unset
        if isinstance(_plan_compensation, Unset):
            plan_compensation = UNSET
        else:
            plan_compensation = TypesPlanCompensation.from_dict(_plan_compensation)

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

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

        _transactions = d.pop("transactions", UNSET)
        transactions: TypesTransactions | Unset
        if isinstance(_transactions, Unset):
            transactions = UNSET
        else:
            transactions = TypesTransactions.from_dict(_transactions)

        _vesting = d.pop("vesting", UNSET)
        vesting: TypesVesting | Unset
        if isinstance(_vesting, Unset):
            vesting = UNSET
        else:
            vesting = TypesVesting.from_dict(_vesting)

        _warnings = d.pop("warnings", UNSET)
        warnings: list[TypesWarning] | Unset = UNSET
        if _warnings is not UNSET:
            warnings = []
            for warnings_item_data in _warnings:
                warnings_item = TypesWarning.from_dict(warnings_item_data)

                warnings.append(warnings_item)

        types_plan_data = cls(
            eligibility_date=eligibility_date,
            eligibility_reason=eligibility_reason,
            eligibility_status=eligibility_status,
            eligible_gross_pay=eligible_gross_pay,
            entry_date=entry_date,
            exclusions=exclusions,
            plan_compensation=plan_compensation,
            plan_id=plan_id,
            plan_type=plan_type,
            transactions=transactions,
            vesting=vesting,
            warnings=warnings,
        )

        types_plan_data.additional_properties = d
        return types_plan_data

    @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
