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.stax_ai_cx_cx_api_pkg_routes_helpers_attachment import StaxAiCxCxApiPkgRoutesHelpersAttachment


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


@_attrs_define
class StaxAiCxCxApiPkgRoutesHelpersDCGAttachment:
    """
    Attributes:
        attachments (list[StaxAiCxCxApiPkgRoutesHelpersAttachment] | Unset):
        ein (str | Unset):
        plan_num (str | Unset):
    """

    attachments: list[StaxAiCxCxApiPkgRoutesHelpersAttachment] | Unset = UNSET
    ein: str | Unset = UNSET
    plan_num: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        ein = self.ein

        plan_num = self.plan_num

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if attachments is not UNSET:
            field_dict["attachments"] = attachments
        if ein is not UNSET:
            field_dict["ein"] = ein
        if plan_num is not UNSET:
            field_dict["plan_num"] = plan_num

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        from ..models.stax_ai_cx_cx_api_pkg_routes_helpers_attachment import StaxAiCxCxApiPkgRoutesHelpersAttachment

        d = dict(src_dict)
        _attachments = d.pop("attachments", UNSET)
        attachments: list[StaxAiCxCxApiPkgRoutesHelpersAttachment] | Unset = UNSET
        if _attachments is not UNSET:
            attachments = []
            for attachments_item_data in _attachments:
                attachments_item = StaxAiCxCxApiPkgRoutesHelpersAttachment.from_dict(attachments_item_data)

                attachments.append(attachments_item)

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

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

        stax_ai_cx_cx_api_pkg_routes_helpers_dcg_attachment = cls(
            attachments=attachments,
            ein=ein,
            plan_num=plan_num,
        )

        stax_ai_cx_cx_api_pkg_routes_helpers_dcg_attachment.additional_properties = d
        return stax_ai_cx_cx_api_pkg_routes_helpers_dcg_attachment

    @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
