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_stripe_config_subscription_items import TypesStripeConfigSubscriptionItems


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


@_attrs_define
class TypesStripeConfig:
    """
    Attributes:
        customer_id (str | Unset):
        subscription_id (str | Unset):
        subscription_items (TypesStripeConfigSubscriptionItems | Unset):
    """

    customer_id: str | Unset = UNSET
    subscription_id: str | Unset = UNSET
    subscription_items: TypesStripeConfigSubscriptionItems | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        subscription_id = self.subscription_id

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

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if customer_id is not UNSET:
            field_dict["customer_id"] = customer_id
        if subscription_id is not UNSET:
            field_dict["subscription_id"] = subscription_id
        if subscription_items is not UNSET:
            field_dict["subscription_items"] = subscription_items

        return field_dict

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

        d = dict(src_dict)
        customer_id = d.pop("customer_id", UNSET)

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

        _subscription_items = d.pop("subscription_items", UNSET)
        subscription_items: TypesStripeConfigSubscriptionItems | Unset
        if isinstance(_subscription_items, Unset):
            subscription_items = UNSET
        else:
            subscription_items = TypesStripeConfigSubscriptionItems.from_dict(_subscription_items)

        types_stripe_config = cls(
            customer_id=customer_id,
            subscription_id=subscription_id,
            subscription_items=subscription_items,
        )

        types_stripe_config.additional_properties = d
        return types_stripe_config

    @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
