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="TypesAttachment")


@_attrs_define
class TypesAttachment:
    """
    Attributes:
        content_id (str | Unset):
        file (str | Unset):
        filename (str | Unset):
        is_inline (bool | Unset):
        size (int | Unset):
        source_id (str | Unset):
        url (str | Unset):
    """

    content_id: str | Unset = UNSET
    file: str | Unset = UNSET
    filename: str | Unset = UNSET
    is_inline: bool | Unset = UNSET
    size: int | Unset = UNSET
    source_id: str | Unset = UNSET
    url: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        file = self.file

        filename = self.filename

        is_inline = self.is_inline

        size = self.size

        source_id = self.source_id

        url = self.url

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if content_id is not UNSET:
            field_dict["content_id"] = content_id
        if file is not UNSET:
            field_dict["file"] = file
        if filename is not UNSET:
            field_dict["filename"] = filename
        if is_inline is not UNSET:
            field_dict["isInline"] = is_inline
        if size is not UNSET:
            field_dict["size"] = size
        if source_id is not UNSET:
            field_dict["source_id"] = source_id
        if url is not UNSET:
            field_dict["url"] = url

        return field_dict

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

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

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

        is_inline = d.pop("isInline", UNSET)

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

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

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

        types_attachment = cls(
            content_id=content_id,
            file=file,
            filename=filename,
            is_inline=is_inline,
            size=size,
            source_id=source_id,
            url=url,
        )

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