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_activity import TypesActivity


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


@_attrs_define
class PkgRoutesDealsUpdateDealResponse:
    """
    Attributes:
        activity (list[TypesActivity] | Unset):
        ok (bool | Unset):
    """

    activity: list[TypesActivity] | Unset = UNSET
    ok: bool | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        ok = self.ok

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if activity is not UNSET:
            field_dict["activity"] = activity
        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_activity import TypesActivity

        d = dict(src_dict)
        _activity = d.pop("activity", UNSET)
        activity: list[TypesActivity] | Unset = UNSET
        if _activity is not UNSET:
            activity = []
            for activity_item_data in _activity:
                activity_item = TypesActivity.from_dict(activity_item_data)

                activity.append(activity_item)

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

        pkg_routes_deals_update_deal_response = cls(
            activity=activity,
            ok=ok,
        )

        pkg_routes_deals_update_deal_response.additional_properties = d
        return pkg_routes_deals_update_deal_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
