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


@_attrs_define
class TypesDeal:
    """
    Attributes:
        field_id (str | Unset):
        client (str | Unset):
        close_date (str | Unset):
        close_probability (float | Unset): Override values
        created_at (str | Unset):
        deleted_at (str | Unset):
        funnel (str | Unset):
        last_activity (str | Unset):
        n_messages (int | Unset):
        n_tasks (int | Unset):
        name (str | Unset):
        owner (str | Unset):
        plan (str | Unset):
        pulse (int | Unset): For returning
        source (str | Unset):
        stage (str | Unset):
        status (str | Unset):
        tags (list[str] | Unset):
        team (str | Unset):
        unread (bool | Unset):
        value (float | Unset):
    """

    field_id: str | Unset = UNSET
    client: str | Unset = UNSET
    close_date: str | Unset = UNSET
    close_probability: float | Unset = UNSET
    created_at: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    funnel: str | Unset = UNSET
    last_activity: str | Unset = UNSET
    n_messages: int | Unset = UNSET
    n_tasks: int | Unset = UNSET
    name: str | Unset = UNSET
    owner: str | Unset = UNSET
    plan: str | Unset = UNSET
    pulse: int | Unset = UNSET
    source: str | Unset = UNSET
    stage: str | Unset = UNSET
    status: str | Unset = UNSET
    tags: list[str] | Unset = UNSET
    team: str | Unset = UNSET
    unread: bool | Unset = UNSET
    value: float | 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

        client = self.client

        close_date = self.close_date

        close_probability = self.close_probability

        created_at = self.created_at

        deleted_at = self.deleted_at

        funnel = self.funnel

        last_activity = self.last_activity

        n_messages = self.n_messages

        n_tasks = self.n_tasks

        name = self.name

        owner = self.owner

        plan = self.plan

        pulse = self.pulse

        source = self.source

        stage = self.stage

        status = self.status

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

        team = self.team

        unread = self.unread

        value = self.value

        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 client is not UNSET:
            field_dict["client"] = client
        if close_date is not UNSET:
            field_dict["close_date"] = close_date
        if close_probability is not UNSET:
            field_dict["close_probability"] = close_probability
        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 funnel is not UNSET:
            field_dict["funnel"] = funnel
        if last_activity is not UNSET:
            field_dict["last_activity"] = last_activity
        if n_messages is not UNSET:
            field_dict["n_messages"] = n_messages
        if n_tasks is not UNSET:
            field_dict["n_tasks"] = n_tasks
        if name is not UNSET:
            field_dict["name"] = name
        if owner is not UNSET:
            field_dict["owner"] = owner
        if plan is not UNSET:
            field_dict["plan"] = plan
        if pulse is not UNSET:
            field_dict["pulse"] = pulse
        if source is not UNSET:
            field_dict["source"] = source
        if stage is not UNSET:
            field_dict["stage"] = stage
        if status is not UNSET:
            field_dict["status"] = status
        if tags is not UNSET:
            field_dict["tags"] = tags
        if team is not UNSET:
            field_dict["team"] = team
        if unread is not UNSET:
            field_dict["unread"] = unread
        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)
        field_id = d.pop("_id", UNSET)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        types_deal = cls(
            field_id=field_id,
            client=client,
            close_date=close_date,
            close_probability=close_probability,
            created_at=created_at,
            deleted_at=deleted_at,
            funnel=funnel,
            last_activity=last_activity,
            n_messages=n_messages,
            n_tasks=n_tasks,
            name=name,
            owner=owner,
            plan=plan,
            pulse=pulse,
            source=source,
            stage=stage,
            status=status,
            tags=tags,
            team=team,
            unread=unread,
            value=value,
        )

        types_deal.additional_properties = d
        return types_deal

    @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
