from __future__ import annotations

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

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

from ..types import UNSET, Unset

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


@_attrs_define
class TypesCustomField:
    """
    Attributes:
        field_id (str | Unset):
        creatable (bool | Unset):
        default (Any | Unset):
        formats (list[str] | Unset): File upload formats
        hint (str | Unset):
        key (str | Unset):
        link (str | Unset):
        multiple (bool | Unset):
        on_type (str | Unset):
        options (list[str] | Unset): Dropdown options
        question (str | Unset):
        required (bool | Unset):
        starred (bool | Unset):
        subtypes (list[str] | Unset):
        team (str | Unset):
        title (str | Unset):
        type_ (str | Unset):
    """

    field_id: str | Unset = UNSET
    creatable: bool | Unset = UNSET
    default: Any | Unset = UNSET
    formats: list[str] | Unset = UNSET
    hint: str | Unset = UNSET
    key: str | Unset = UNSET
    link: str | Unset = UNSET
    multiple: bool | Unset = UNSET
    on_type: str | Unset = UNSET
    options: list[str] | Unset = UNSET
    question: str | Unset = UNSET
    required: bool | Unset = UNSET
    starred: bool | Unset = UNSET
    subtypes: list[str] | Unset = UNSET
    team: str | Unset = UNSET
    title: str | Unset = UNSET
    type_: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        creatable = self.creatable

        default = self.default

        formats: list[str] | Unset = UNSET
        if not isinstance(self.formats, Unset):
            formats = self.formats

        hint = self.hint

        key = self.key

        link = self.link

        multiple = self.multiple

        on_type = self.on_type

        options: list[str] | Unset = UNSET
        if not isinstance(self.options, Unset):
            options = self.options

        question = self.question

        required = self.required

        starred = self.starred

        subtypes: list[str] | Unset = UNSET
        if not isinstance(self.subtypes, Unset):
            subtypes = self.subtypes

        team = self.team

        title = self.title

        type_ = self.type_

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if field_id is not UNSET:
            field_dict["_id"] = field_id
        if creatable is not UNSET:
            field_dict["creatable"] = creatable
        if default is not UNSET:
            field_dict["default"] = default
        if formats is not UNSET:
            field_dict["formats"] = formats
        if hint is not UNSET:
            field_dict["hint"] = hint
        if key is not UNSET:
            field_dict["key"] = key
        if link is not UNSET:
            field_dict["link"] = link
        if multiple is not UNSET:
            field_dict["multiple"] = multiple
        if on_type is not UNSET:
            field_dict["on_type"] = on_type
        if options is not UNSET:
            field_dict["options"] = options
        if question is not UNSET:
            field_dict["question"] = question
        if required is not UNSET:
            field_dict["required"] = required
        if starred is not UNSET:
            field_dict["starred"] = starred
        if subtypes is not UNSET:
            field_dict["subtypes"] = subtypes
        if team is not UNSET:
            field_dict["team"] = team
        if title is not UNSET:
            field_dict["title"] = title
        if type_ is not UNSET:
            field_dict["type"] = type_

        return field_dict

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

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

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

        formats = cast(list[str], d.pop("formats", UNSET))

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

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

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

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

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

        options = cast(list[str], d.pop("options", UNSET))

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

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

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

        subtypes = cast(list[str], d.pop("subtypes", UNSET))

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

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

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

        types_custom_field = cls(
            field_id=field_id,
            creatable=creatable,
            default=default,
            formats=formats,
            hint=hint,
            key=key,
            link=link,
            multiple=multiple,
            on_type=on_type,
            options=options,
            question=question,
            required=required,
            starred=starred,
            subtypes=subtypes,
            team=team,
            title=title,
            type_=type_,
        )

        types_custom_field.additional_properties = d
        return types_custom_field

    @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
