# coding: utf-8

"""
    YouTube Data API v3

    The YouTube Data API v3 is an API that provides access to YouTube data, such as videos, playlists, and channels.

    The version of the OpenAPI document: v3
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from youtube_ti.models.live_chat_fan_funding_event_details import LiveChatFanFundingEventDetails
from youtube_ti.models.live_chat_gift_membership_received_details import LiveChatGiftMembershipReceivedDetails
from youtube_ti.models.live_chat_member_milestone_chat_details import LiveChatMemberMilestoneChatDetails
from youtube_ti.models.live_chat_membership_gifting_details import LiveChatMembershipGiftingDetails
from youtube_ti.models.live_chat_message_deleted_details import LiveChatMessageDeletedDetails
from youtube_ti.models.live_chat_message_retracted_details import LiveChatMessageRetractedDetails
from youtube_ti.models.live_chat_new_sponsor_details import LiveChatNewSponsorDetails
from youtube_ti.models.live_chat_poll_details import LiveChatPollDetails
from youtube_ti.models.live_chat_super_chat_details import LiveChatSuperChatDetails
from youtube_ti.models.live_chat_super_sticker_details import LiveChatSuperStickerDetails
from youtube_ti.models.live_chat_text_message_details import LiveChatTextMessageDetails
from youtube_ti.models.live_chat_user_banned_message_details import LiveChatUserBannedMessageDetails
from typing import Optional, Set
from typing_extensions import Self

class LiveChatMessageSnippet(BaseModel):
    """
    Next ID: 34
    """ # noqa: E501
    author_channel_id: Optional[StrictStr] = Field(default=None, description="The ID of the user that authored this message, this field is not always filled. textMessageEvent - the user that wrote the message fanFundingEvent - the user that funded the broadcast newSponsorEvent - the user that just became a sponsor memberMilestoneChatEvent - the member that sent the message membershipGiftingEvent - the user that made the purchase giftMembershipReceivedEvent - the user that received the gift membership messageDeletedEvent - the moderator that took the action messageRetractedEvent - the author that retracted their message userBannedEvent - the moderator that took the action superChatEvent - the user that made the purchase superStickerEvent - the user that made the purchase pollEvent - the user that created the poll", alias="authorChannelId")
    display_message: Optional[StrictStr] = Field(default=None, description="Contains a string that can be displayed to the user. If this field is not present the message is silent, at the moment only messages of type TOMBSTONE and CHAT_ENDED_EVENT are silent.", alias="displayMessage")
    fan_funding_event_details: Optional[LiveChatFanFundingEventDetails] = Field(default=None, alias="fanFundingEventDetails")
    gift_membership_received_details: Optional[LiveChatGiftMembershipReceivedDetails] = Field(default=None, alias="giftMembershipReceivedDetails")
    has_display_content: Optional[StrictBool] = Field(default=None, description="Whether the message has display content that should be displayed to users.", alias="hasDisplayContent")
    live_chat_id: Optional[StrictStr] = Field(default=None, alias="liveChatId")
    member_milestone_chat_details: Optional[LiveChatMemberMilestoneChatDetails] = Field(default=None, alias="memberMilestoneChatDetails")
    membership_gifting_details: Optional[LiveChatMembershipGiftingDetails] = Field(default=None, alias="membershipGiftingDetails")
    message_deleted_details: Optional[LiveChatMessageDeletedDetails] = Field(default=None, alias="messageDeletedDetails")
    message_retracted_details: Optional[LiveChatMessageRetractedDetails] = Field(default=None, alias="messageRetractedDetails")
    new_sponsor_details: Optional[LiveChatNewSponsorDetails] = Field(default=None, alias="newSponsorDetails")
    poll_details: Optional[LiveChatPollDetails] = Field(default=None, alias="pollDetails")
    published_at: Optional[datetime] = Field(default=None, description="The date and time when the message was orignally published.", alias="publishedAt")
    super_chat_details: Optional[LiveChatSuperChatDetails] = Field(default=None, alias="superChatDetails")
    super_sticker_details: Optional[LiveChatSuperStickerDetails] = Field(default=None, alias="superStickerDetails")
    text_message_details: Optional[LiveChatTextMessageDetails] = Field(default=None, alias="textMessageDetails")
    type: Optional[StrictStr] = Field(default=None, description="The type of message, this will always be present, it determines the contents of the message as well as which fields will be present.")
    user_banned_details: Optional[LiveChatUserBannedMessageDetails] = Field(default=None, alias="userBannedDetails")
    __properties: ClassVar[List[str]] = ["authorChannelId", "displayMessage", "fanFundingEventDetails", "giftMembershipReceivedDetails", "hasDisplayContent", "liveChatId", "memberMilestoneChatDetails", "membershipGiftingDetails", "messageDeletedDetails", "messageRetractedDetails", "newSponsorDetails", "pollDetails", "publishedAt", "superChatDetails", "superStickerDetails", "textMessageDetails", "type", "userBannedDetails"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['invalidType', 'textMessageEvent', 'tombstone', 'fanFundingEvent', 'chatEndedEvent', 'sponsorOnlyModeStartedEvent', 'sponsorOnlyModeEndedEvent', 'newSponsorEvent', 'memberMilestoneChatEvent', 'membershipGiftingEvent', 'giftMembershipReceivedEvent', 'messageDeletedEvent', 'messageRetractedEvent', 'userBannedEvent', 'superChatEvent', 'superStickerEvent', 'pollEvent']):
            raise ValueError("must be one of enum values ('invalidType', 'textMessageEvent', 'tombstone', 'fanFundingEvent', 'chatEndedEvent', 'sponsorOnlyModeStartedEvent', 'sponsorOnlyModeEndedEvent', 'newSponsorEvent', 'memberMilestoneChatEvent', 'membershipGiftingEvent', 'giftMembershipReceivedEvent', 'messageDeletedEvent', 'messageRetractedEvent', 'userBannedEvent', 'superChatEvent', 'superStickerEvent', 'pollEvent')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of LiveChatMessageSnippet from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of fan_funding_event_details
        if self.fan_funding_event_details:
            _dict['fanFundingEventDetails'] = self.fan_funding_event_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of gift_membership_received_details
        if self.gift_membership_received_details:
            _dict['giftMembershipReceivedDetails'] = self.gift_membership_received_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of member_milestone_chat_details
        if self.member_milestone_chat_details:
            _dict['memberMilestoneChatDetails'] = self.member_milestone_chat_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of membership_gifting_details
        if self.membership_gifting_details:
            _dict['membershipGiftingDetails'] = self.membership_gifting_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of message_deleted_details
        if self.message_deleted_details:
            _dict['messageDeletedDetails'] = self.message_deleted_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of message_retracted_details
        if self.message_retracted_details:
            _dict['messageRetractedDetails'] = self.message_retracted_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of new_sponsor_details
        if self.new_sponsor_details:
            _dict['newSponsorDetails'] = self.new_sponsor_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of poll_details
        if self.poll_details:
            _dict['pollDetails'] = self.poll_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of super_chat_details
        if self.super_chat_details:
            _dict['superChatDetails'] = self.super_chat_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of super_sticker_details
        if self.super_sticker_details:
            _dict['superStickerDetails'] = self.super_sticker_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of text_message_details
        if self.text_message_details:
            _dict['textMessageDetails'] = self.text_message_details.to_dict()
        # override the default output from pydantic by calling `to_dict()` of user_banned_details
        if self.user_banned_details:
            _dict['userBannedDetails'] = self.user_banned_details.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of LiveChatMessageSnippet from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "authorChannelId": obj.get("authorChannelId"),
            "displayMessage": obj.get("displayMessage"),
            "fanFundingEventDetails": LiveChatFanFundingEventDetails.from_dict(obj["fanFundingEventDetails"]) if obj.get("fanFundingEventDetails") is not None else None,
            "giftMembershipReceivedDetails": LiveChatGiftMembershipReceivedDetails.from_dict(obj["giftMembershipReceivedDetails"]) if obj.get("giftMembershipReceivedDetails") is not None else None,
            "hasDisplayContent": obj.get("hasDisplayContent"),
            "liveChatId": obj.get("liveChatId"),
            "memberMilestoneChatDetails": LiveChatMemberMilestoneChatDetails.from_dict(obj["memberMilestoneChatDetails"]) if obj.get("memberMilestoneChatDetails") is not None else None,
            "membershipGiftingDetails": LiveChatMembershipGiftingDetails.from_dict(obj["membershipGiftingDetails"]) if obj.get("membershipGiftingDetails") is not None else None,
            "messageDeletedDetails": LiveChatMessageDeletedDetails.from_dict(obj["messageDeletedDetails"]) if obj.get("messageDeletedDetails") is not None else None,
            "messageRetractedDetails": LiveChatMessageRetractedDetails.from_dict(obj["messageRetractedDetails"]) if obj.get("messageRetractedDetails") is not None else None,
            "newSponsorDetails": LiveChatNewSponsorDetails.from_dict(obj["newSponsorDetails"]) if obj.get("newSponsorDetails") is not None else None,
            "pollDetails": LiveChatPollDetails.from_dict(obj["pollDetails"]) if obj.get("pollDetails") is not None else None,
            "publishedAt": obj.get("publishedAt"),
            "superChatDetails": LiveChatSuperChatDetails.from_dict(obj["superChatDetails"]) if obj.get("superChatDetails") is not None else None,
            "superStickerDetails": LiveChatSuperStickerDetails.from_dict(obj["superStickerDetails"]) if obj.get("superStickerDetails") is not None else None,
            "textMessageDetails": LiveChatTextMessageDetails.from_dict(obj["textMessageDetails"]) if obj.get("textMessageDetails") is not None else None,
            "type": obj.get("type"),
            "userBannedDetails": LiveChatUserBannedMessageDetails.from_dict(obj["userBannedDetails"]) if obj.get("userBannedDetails") is not None else None
        })
        return _obj


