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


@_attrs_define
class LegacytypesClientAccess:
    """
    Attributes:
        accepted_on (str | Unset):
        client (str | Unset):
        contact (str | Unset):
        invited_on (str | Unset):
        scopes (list[str] | Unset):
        team (str | Unset):
    """

    accepted_on: str | Unset = UNSET
    client: str | Unset = UNSET
    contact: str | Unset = UNSET
    invited_on: str | Unset = UNSET
    scopes: list[str] | Unset = UNSET
    team: str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

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

        client = self.client

        contact = self.contact

        invited_on = self.invited_on

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

        team = self.team

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if accepted_on is not UNSET:
            field_dict["accepted_on"] = accepted_on
        if client is not UNSET:
            field_dict["client"] = client
        if contact is not UNSET:
            field_dict["contact"] = contact
        if invited_on is not UNSET:
            field_dict["invited_on"] = invited_on
        if scopes is not UNSET:
            field_dict["scopes"] = scopes
        if team is not UNSET:
            field_dict["team"] = team

        return field_dict

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

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

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

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

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

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

        legacytypes_client_access = cls(
            accepted_on=accepted_on,
            client=client,
            contact=contact,
            invited_on=invited_on,
            scopes=scopes,
            team=team,
        )

        legacytypes_client_access.additional_properties = d
        return legacytypes_client_access

    @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
