r"""
    This code was generated by
   ___ _ _ _ _ _    _ ____    ____ ____ _    ____ ____ _  _ ____ ____ ____ ___ __   __
    |  | | | | |    | |  | __ |  | |__| | __ | __ |___ |\ | |___ |__/ |__|  | |  | |__/
    |  |_|_| | |___ | |__|    |__| |  | |    |__] |___ | \| |___ |  \ |  |  | |__| |  \

    Twilio - Messaging
    This is the public Twilio REST API.

    NOTE: This class is auto generated by OpenAPI Generator.
    https://openapi-generator.tech
    Do not edit the class manually.
"""

from typing import Any, Dict, Optional
from twilio.base import values

from twilio.base.instance_resource import InstanceResource
from twilio.base.list_resource import ListResource
from twilio.base.version import Version


class TypingIndicatorInstance(InstanceResource):
    """
    :ivar success: Indicates if the typing indicator was sent successfully.
    """

    def __init__(self, version: Version, payload: Dict[str, Any]):
        super().__init__(version)

        self.success: Optional[bool] = payload.get("success")

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """

        return "<Twilio.Messaging.V2.TypingIndicatorInstance>"


class TypingIndicatorList(ListResource):

    def __init__(self, version: Version):
        """
        Initialize the TypingIndicatorList

        :param version: Version that contains the resource

        """
        super().__init__(version)

        self._uri = "/Indicators/Typing.json"

    def create(self, channel: str, message_id: str) -> TypingIndicatorInstance:
        """
        Create the TypingIndicatorInstance

        :param channel: Shared channel identifier
        :param message_id: Message SID that identifies the conversation thread for the typing indicator. Must be a valid Twilio Message SID (SM*) or Media SID (MM*) from an existing WhatsApp conversation.

        :returns: The created TypingIndicatorInstance
        """

        data = values.of(
            {
                "channel": channel,
                "messageId": message_id,
            }
        )
        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        payload = self._version.create(
            method="POST", uri=self._uri, data=data, headers=headers
        )

        return TypingIndicatorInstance(self._version, payload)

    async def create_async(
        self, channel: str, message_id: str
    ) -> TypingIndicatorInstance:
        """
        Asynchronously create the TypingIndicatorInstance

        :param channel: Shared channel identifier
        :param message_id: Message SID that identifies the conversation thread for the typing indicator. Must be a valid Twilio Message SID (SM*) or Media SID (MM*) from an existing WhatsApp conversation.

        :returns: The created TypingIndicatorInstance
        """

        data = values.of(
            {
                "channel": channel,
                "messageId": message_id,
            }
        )
        headers = values.of({"Content-Type": "application/x-www-form-urlencoded"})

        headers["Content-Type"] = "application/x-www-form-urlencoded"

        headers["Accept"] = "application/json"

        payload = await self._version.create_async(
            method="POST", uri=self._uri, data=data, headers=headers
        )

        return TypingIndicatorInstance(self._version, payload)

    def __repr__(self) -> str:
        """
        Provide a friendly representation

        :returns: Machine friendly representation
        """
        return "<Twilio.Messaging.V2.TypingIndicatorList>"
