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


@_attrs_define
class TypesInvitation:
    """
    Attributes:
        field_id (str | Unset):
        accepted_on (str | Unset):
        client (str | Unset): If the invitation is to join a team, the client ID is not set. If it's to join a client,
            the client ID is set
        deleted_at (str | Unset):
        email (str | Unset):
        from_ (str | Unset): User ID
        last_follow_up (str | Unset):
        name (str | Unset): Invitation user details
        scopes (list[str] | Unset):
        sent_on (str | Unset):
        team (str | Unset):
        title (str | Unset):
        user (str | Unset):
    """

    field_id: str | Unset = UNSET
    accepted_on: str | Unset = UNSET
    client: str | Unset = UNSET
    deleted_at: str | Unset = UNSET
    email: str | Unset = UNSET
    from_: str | Unset = UNSET
    last_follow_up: str | Unset = UNSET
    name: str | Unset = UNSET
    scopes: list[str] | Unset = UNSET
    sent_on: str | Unset = UNSET
    team: str | Unset = UNSET
    title: str | Unset = UNSET
    user: 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

        accepted_on = self.accepted_on

        client = self.client

        deleted_at = self.deleted_at

        email = self.email

        from_ = self.from_

        last_follow_up = self.last_follow_up

        name = self.name

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

        sent_on = self.sent_on

        team = self.team

        title = self.title

        user = self.user

        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 accepted_on is not UNSET:
            field_dict["accepted_on"] = accepted_on
        if client is not UNSET:
            field_dict["client"] = client
        if deleted_at is not UNSET:
            field_dict["deleted_at"] = deleted_at
        if email is not UNSET:
            field_dict["email"] = email
        if from_ is not UNSET:
            field_dict["from"] = from_
        if last_follow_up is not UNSET:
            field_dict["last_follow_up"] = last_follow_up
        if name is not UNSET:
            field_dict["name"] = name
        if scopes is not UNSET:
            field_dict["scopes"] = scopes
        if sent_on is not UNSET:
            field_dict["sent_on"] = sent_on
        if team is not UNSET:
            field_dict["team"] = team
        if title is not UNSET:
            field_dict["title"] = title
        if user is not UNSET:
            field_dict["user"] = user

        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)

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

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

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

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

        from_ = d.pop("from", UNSET)

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

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

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

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

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

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

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

        types_invitation = cls(
            field_id=field_id,
            accepted_on=accepted_on,
            client=client,
            deleted_at=deleted_at,
            email=email,
            from_=from_,
            last_follow_up=last_follow_up,
            name=name,
            scopes=scopes,
            sent_on=sent_on,
            team=team,
            title=title,
            user=user,
        )

        types_invitation.additional_properties = d
        return types_invitation

    @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
