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


@_attrs_define
class TypesCommunityTopic:
    """
    Attributes:
        field_id (str | Unset):
        category (str | Unset):
        created_at (str | Unset):
        deleted_at (str | Unset):
        description (str | Unset):
        owner (str | Unset):
        posts (int | Unset):
        resolved (int | Unset):
        starred (bool | Unset):
        threads (int | Unset): For returning
        title (str | Unset):
    """

    field_id: str | Unset = UNSET
    category: str | Unset = UNSET
    created_at: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    description: str | Unset = UNSET
    owner: str | Unset = UNSET
    posts: int | Unset = UNSET
    resolved: int | Unset = UNSET
    starred: bool | Unset = UNSET
    threads: int | Unset = UNSET
    title: 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

        category = self.category

        created_at = self.created_at

        deleted_at = self.deleted_at

        description = self.description

        owner = self.owner

        posts = self.posts

        resolved = self.resolved

        starred = self.starred

        threads = self.threads

        title = self.title

        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 category is not UNSET:
            field_dict["category"] = category
        if created_at is not UNSET:
            field_dict["created_at"] = created_at
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if description is not UNSET:
            field_dict["description"] = description
        if owner is not UNSET:
            field_dict["owner"] = owner
        if posts is not UNSET:
            field_dict["posts"] = posts
        if resolved is not UNSET:
            field_dict["resolved"] = resolved
        if starred is not UNSET:
            field_dict["starred"] = starred
        if threads is not UNSET:
            field_dict["threads"] = threads
        if title is not UNSET:
            field_dict["title"] = title

        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)

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

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

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

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

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

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

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

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

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

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

        types_community_topic = cls(
            field_id=field_id,
            category=category,
            created_at=created_at,
            deleted_at=deleted_at,
            description=description,
            owner=owner,
            posts=posts,
            resolved=resolved,
            starred=starred,
            threads=threads,
            title=title,
        )

        types_community_topic.additional_properties = d
        return types_community_topic

    @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
