from __future__ import annotations

from collections.abc import Mapping
from typing import Any, TypeVar

from attrs import define as _attrs_define
from attrs import field as _attrs_field

from ..types import UNSET, Unset

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


@_attrs_define
class TypesResponse:
    """
    Attributes:
        key (str | Unset):
        link (str | Unset):
        on_type (str | Unset):
        question (str | Unset):
        timestamp (str | Unset):
        title (str | Unset):
        type_ (str | Unset):
        value (Any | Unset):
    """

    key: str | Unset = UNSET
    link: str | Unset = UNSET
    on_type: str | Unset = UNSET
    question: str | Unset = UNSET
    timestamp: str | Unset = UNSET
    title: str | Unset = UNSET
    type_: str | Unset = UNSET
    value: Any | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        link = self.link

        on_type = self.on_type

        question = self.question

        timestamp = self.timestamp

        title = self.title

        type_ = self.type_

        value = self.value

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if key is not UNSET:
            field_dict["key"] = key
        if link is not UNSET:
            field_dict["link"] = link
        if on_type is not UNSET:
            field_dict["on_type"] = on_type
        if question is not UNSET:
            field_dict["question"] = question
        if timestamp is not UNSET:
            field_dict["timestamp"] = timestamp
        if title is not UNSET:
            field_dict["title"] = title
        if type_ is not UNSET:
            field_dict["type"] = type_
        if value is not UNSET:
            field_dict["value"] = value

        return field_dict

    @classmethod
    def from_dict(cls: type[T], src_dict: Mapping[str, Any]) -> T:
        d = dict(src_dict)
        key = d.pop("key", UNSET)

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

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

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

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

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

        type_ = d.pop("type", UNSET)

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

        types_response = cls(
            key=key,
            link=link,
            on_type=on_type,
            question=question,
            timestamp=timestamp,
            title=title,
            type_=type_,
            value=value,
        )

        types_response.additional_properties = d
        return types_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
