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


@_attrs_define
class PostReactionsLiveFetchResponse200OutputDataItemReactorType0:
    """
    Attributes:
        user_id (float | None | Unset):
        entity_urn (None | str | Unset):
        profile_picture (None | str | Unset):
        name (None | str | Unset):
        headline (None | str | Unset):
    """

    user_id: float | None | Unset = UNSET
    entity_urn: None | str | Unset = UNSET
    profile_picture: None | str | Unset = UNSET
    name: None | str | Unset = UNSET
    headline: None | str | Unset = UNSET
    additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

    def to_dict(self) -> dict[str, Any]:
        user_id: float | None | Unset
        if isinstance(self.user_id, Unset):
            user_id = UNSET
        else:
            user_id = self.user_id

        entity_urn: None | str | Unset
        if isinstance(self.entity_urn, Unset):
            entity_urn = UNSET
        else:
            entity_urn = self.entity_urn

        profile_picture: None | str | Unset
        if isinstance(self.profile_picture, Unset):
            profile_picture = UNSET
        else:
            profile_picture = self.profile_picture

        name: None | str | Unset
        if isinstance(self.name, Unset):
            name = UNSET
        else:
            name = self.name

        headline: None | str | Unset
        if isinstance(self.headline, Unset):
            headline = UNSET
        else:
            headline = self.headline

        field_dict: dict[str, Any] = {}
        field_dict.update(self.additional_properties)
        field_dict.update({})
        if user_id is not UNSET:
            field_dict["userId"] = user_id
        if entity_urn is not UNSET:
            field_dict["entityUrn"] = entity_urn
        if profile_picture is not UNSET:
            field_dict["profilePicture"] = profile_picture
        if name is not UNSET:
            field_dict["name"] = name
        if headline is not UNSET:
            field_dict["headline"] = headline

        return field_dict

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

        def _parse_user_id(data: object) -> float | None | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(float | None | Unset, data)

        user_id = _parse_user_id(d.pop("userId", UNSET))

        def _parse_entity_urn(data: object) -> None | str | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(None | str | Unset, data)

        entity_urn = _parse_entity_urn(d.pop("entityUrn", UNSET))

        def _parse_profile_picture(data: object) -> None | str | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(None | str | Unset, data)

        profile_picture = _parse_profile_picture(d.pop("profilePicture", UNSET))

        def _parse_name(data: object) -> None | str | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(None | str | Unset, data)

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

        def _parse_headline(data: object) -> None | str | Unset:
            if data is None:
                return data
            if isinstance(data, Unset):
                return data
            return cast(None | str | Unset, data)

        headline = _parse_headline(d.pop("headline", UNSET))

        post_reactions_live_fetch_response_200_output_data_item_reactor_type_0 = cls(
            user_id=user_id,
            entity_urn=entity_urn,
            profile_picture=profile_picture,
            name=name,
            headline=headline,
        )

        post_reactions_live_fetch_response_200_output_data_item_reactor_type_0.additional_properties = d
        return post_reactions_live_fetch_response_200_output_data_item_reactor_type_0

    @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
