# This file was auto-generated by Fern from our API Definition.

import typing

from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ...core.request_options import RequestOptions
from ...types.rcs_validate_content import RcsValidateContent
from ...types.rcs_validation_result import RcsValidationResult
from ...types.rich_message import RichMessage
from ...types.send_typing_indicator_response import SendTypingIndicatorResponse
from .raw_client import AsyncRawRcsClient, RawRcsClient
from .types.send_rich_message_response import SendRichMessageResponse
from .types.send_typing_indicator_schema_options import SendTypingIndicatorSchemaOptions

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class RcsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawRcsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> RawRcsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        RawRcsClient
        """
        return self._raw_client

    def send(
        self, *, request: RichMessage, request_options: typing.Optional[RequestOptions] = None
    ) -> SendRichMessageResponse:
        """
        Send a RCS message immediately or schedule it for future delivery. <br>

        Requires an active RCS agent and recipient devices that support RCS Business Messaging.

        Parameters
        ----------
        request : RichMessage

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SendRichMessageResponse
            Successfully sent or scheduled the message.

            Use our [/messages/:id](./get) endpoint to track your message.

        Examples
        --------
        from rcs import Pinnacle, RichButton_OpenUrl, RichTextMessage

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.rcs.send(
            request=RichTextMessage(
                quick_replies=[
                    RichButton_OpenUrl(
                        payload="payload",
                        title="title",
                    )
                ],
                text="text",
                from_="from",
                to="to",
            ),
        )
        """
        _response = self._raw_client.send(request=request, request_options=request_options)
        return _response.data

    def send_typing(
        self,
        *,
        agent_id: str,
        to: str,
        options: typing.Optional[SendTypingIndicatorSchemaOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SendTypingIndicatorResponse:
        """
        Send a typing indicator from an RCS agent to a recipient.

        This endpoint allows RCS agents to display a typing indicator to recipients. The indicator is a message bubble with animated typing dots like this: <img src="https://server.trypinnacle.app/storage/v1/object/public/pinnacle-public-assets/ios-typing-indicator.png" alt="Typing Indicator" style="display: inline; height: 1.5em; vertical-align: middle; margin: 0 4px;" />

        **Use Case:** Typing indicators are especially useful for providing feedback to users while the agent is thinking or generating a response that may take some time, creating a more engaging conversational experience.

        **Expiration:** Typing indicators automatically expire after around 20 seconds or when the agent sends a message, whichever comes first.

        **Frequency:** You can send typing indicators as many times as needed, though only one will be displayed at a time. Sending multiple typing indicators will extend the duration of the current indicator.

        > **Note:** Typing indicators are best-effort hints, not delivery-guaranteed state. The platform is allowed to coalesce or drop them, and the client UI decides when to show/hide.

        Parameters
        ----------
        agent_id : str
            The unique identifier of the RCS agent sending the typing indicator. <br>

            Format: `agent_` followed by alphanumeric characters (e.g., `agent_pinnacle`).

        to : str
            The recipient's phone number in E.164 format. <br>

            Must include country code with a leading plus sign (e.g., `+14155551234`).

        options : typing.Optional[SendTypingIndicatorSchemaOptions]
            Configure how your typing indicator is sent.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SendTypingIndicatorResponse
            Successfully sent the typing indicator.

        Examples
        --------
        from rcs import Pinnacle
        from rcs.messages.rcs import SendTypingIndicatorSchemaOptions

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.rcs.send_typing(
            agent_id="agent_pinnacle",
            to="+14154746461",
            options=SendTypingIndicatorSchemaOptions(
                test_mode=False,
            ),
        )
        """
        _response = self._raw_client.send_typing(
            agent_id=agent_id, to=to, options=options, request_options=request_options
        )
        return _response.data

    def validate(
        self, *, request: RcsValidateContent, request_options: typing.Optional[RequestOptions] = None
    ) -> RcsValidationResult:
        """
        Validate RCS message content without sending it.

        Parameters
        ----------
        request : RcsValidateContent

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        RcsValidationResult
            Returns validation results.

        Examples
        --------
        from rcs import Pinnacle, RichButton_OpenUrl, RichText

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.rcs.validate(
            request=RichText(
                quick_replies=[
                    RichButton_OpenUrl(
                        payload="payload",
                        title="title",
                    )
                ],
                text="text",
            ),
        )
        """
        _response = self._raw_client.validate(request=request, request_options=request_options)
        return _response.data


class AsyncRcsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawRcsClient(client_wrapper=client_wrapper)

    @property
    def with_raw_response(self) -> AsyncRawRcsClient:
        """
        Retrieves a raw implementation of this client that returns raw responses.

        Returns
        -------
        AsyncRawRcsClient
        """
        return self._raw_client

    async def send(
        self, *, request: RichMessage, request_options: typing.Optional[RequestOptions] = None
    ) -> SendRichMessageResponse:
        """
        Send a RCS message immediately or schedule it for future delivery. <br>

        Requires an active RCS agent and recipient devices that support RCS Business Messaging.

        Parameters
        ----------
        request : RichMessage

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SendRichMessageResponse
            Successfully sent or scheduled the message.

            Use our [/messages/:id](./get) endpoint to track your message.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle, RichButton_OpenUrl, RichTextMessage

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.rcs.send(
                request=RichTextMessage(
                    quick_replies=[
                        RichButton_OpenUrl(
                            payload="payload",
                            title="title",
                        )
                    ],
                    text="text",
                    from_="from",
                    to="to",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.send(request=request, request_options=request_options)
        return _response.data

    async def send_typing(
        self,
        *,
        agent_id: str,
        to: str,
        options: typing.Optional[SendTypingIndicatorSchemaOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SendTypingIndicatorResponse:
        """
        Send a typing indicator from an RCS agent to a recipient.

        This endpoint allows RCS agents to display a typing indicator to recipients. The indicator is a message bubble with animated typing dots like this: <img src="https://server.trypinnacle.app/storage/v1/object/public/pinnacle-public-assets/ios-typing-indicator.png" alt="Typing Indicator" style="display: inline; height: 1.5em; vertical-align: middle; margin: 0 4px;" />

        **Use Case:** Typing indicators are especially useful for providing feedback to users while the agent is thinking or generating a response that may take some time, creating a more engaging conversational experience.

        **Expiration:** Typing indicators automatically expire after around 20 seconds or when the agent sends a message, whichever comes first.

        **Frequency:** You can send typing indicators as many times as needed, though only one will be displayed at a time. Sending multiple typing indicators will extend the duration of the current indicator.

        > **Note:** Typing indicators are best-effort hints, not delivery-guaranteed state. The platform is allowed to coalesce or drop them, and the client UI decides when to show/hide.

        Parameters
        ----------
        agent_id : str
            The unique identifier of the RCS agent sending the typing indicator. <br>

            Format: `agent_` followed by alphanumeric characters (e.g., `agent_pinnacle`).

        to : str
            The recipient's phone number in E.164 format. <br>

            Must include country code with a leading plus sign (e.g., `+14155551234`).

        options : typing.Optional[SendTypingIndicatorSchemaOptions]
            Configure how your typing indicator is sent.

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SendTypingIndicatorResponse
            Successfully sent the typing indicator.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle
        from rcs.messages.rcs import SendTypingIndicatorSchemaOptions

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.rcs.send_typing(
                agent_id="agent_pinnacle",
                to="+14154746461",
                options=SendTypingIndicatorSchemaOptions(
                    test_mode=False,
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.send_typing(
            agent_id=agent_id, to=to, options=options, request_options=request_options
        )
        return _response.data

    async def validate(
        self, *, request: RcsValidateContent, request_options: typing.Optional[RequestOptions] = None
    ) -> RcsValidationResult:
        """
        Validate RCS message content without sending it.

        Parameters
        ----------
        request : RcsValidateContent

        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        RcsValidationResult
            Returns validation results.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle, RichButton_OpenUrl, RichText

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.rcs.validate(
                request=RichText(
                    quick_replies=[
                        RichButton_OpenUrl(
                            payload="payload",
                            title="title",
                        )
                    ],
                    text="text",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.validate(request=request, request_options=request_options)
        return _response.data
