# 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.mms_content import MmsContent
from ...types.rcs_validate_content import RcsValidateContent
from ...types.sms_content import SmsContent
from .raw_client import AsyncRawBlastClient, RawBlastClient
from .types.blast_mms_options import BlastMmsOptions
from .types.blast_mms_response import BlastMmsResponse
from .types.blast_rcs_options import BlastRcsOptions
from .types.blast_rcs_response import BlastRcsResponse
from .types.blast_sms_options import BlastSmsOptions
from .types.blast_sms_response import BlastSmsResponse

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


class BlastClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBlastClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBlastClient
        """
        return self._raw_client

    def sms(
        self,
        *,
        audience_id: str,
        senders: typing.Sequence[str],
        message: SmsContent,
        options: typing.Optional[BlastSmsOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BlastSmsResponse:
        """
        Send an SMS message to all contacts in an audience. <br>

        Messages are distributed evenly across the provided sender phone numbers. <br>

        Use the optional `schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.

        Parameters
        ----------
        audience_id : str
            The audience ID to send the blast to. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. <br>

            You can create an audience via [the dashboard](https://app.pinnacle.sh/dashboard/audiences) or [API](/api-reference/audiences/create).

        senders : typing.Sequence[str]
            Array of phone numbers to send from in E.164 format. <br>

            Messages will be distributed evenly across these senders.

            > **Note:** Sandbox numbers cannot be used for blasts.

            **Limit:** 1 min

        message : SmsContent

        options : typing.Optional[BlastSmsOptions]
            Additional settings to customize SMS blast delivery.

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

        Returns
        -------
        BlastSmsResponse
            Successfully queued or scheduled the SMS blast. <br>

            - **Immediate blast**: Returns blast details including total recipients, messages, segments, and cost.
            - **Scheduled blast**: Returns a `scheduleId` and the schedule configuration.

        Examples
        --------
        from rcs import Pinnacle, SmsContent

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.blast.sms(
            audience_id="aud_abc123",
            senders=["+14155164736", "+14155164737"],
            message=SmsContent(
                text="Hello from Pinnacle!",
            ),
        )
        """
        _response = self._raw_client.sms(
            audience_id=audience_id, senders=senders, message=message, options=options, request_options=request_options
        )
        return _response.data

    def mms(
        self,
        *,
        audience_id: str,
        senders: typing.Sequence[str],
        message: MmsContent,
        options: typing.Optional[BlastMmsOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BlastMmsResponse:
        """
        Send an MMS message to all contacts in an audience. <br>

        Messages are distributed evenly across the provided sender phone numbers. <br>

        Use the optional `schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.

        Parameters
        ----------
        audience_id : str
            The audience ID to send the blast to. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. <br>

            You can create an audience via [the dashboard](https://app.pinnacle.sh/dashboard/audiences) or [API](/api-reference/audiences/create).

        senders : typing.Sequence[str]
            Array of phone numbers to send from in E.164 format. <br>

            Messages will be distributed evenly across these senders.

            > **Note:** Sandbox numbers cannot be used for blasts.

            **Limit:** 1 min

        message : MmsContent

        options : typing.Optional[BlastMmsOptions]
            Additional settings to customize MMS blast delivery.

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

        Returns
        -------
        BlastMmsResponse
            Successfully queued or scheduled the MMS blast. <br>

            - **Immediate blast**: Returns blast details including total recipients, messages, segments, and cost.
            - **Scheduled blast**: Returns a `scheduleId` and the schedule configuration.

        Examples
        --------
        from rcs import MmsContent, Pinnacle
        from rcs.messages.blast import BlastMmsOptions

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.blast.mms(
            audience_id="aud_abc123",
            senders=["+14155164736", "+14155164737"],
            message=MmsContent(
                media_urls=["https://fastly.picsum.photos/id/941/300/300.jpg"],
                text="Check out this image!",
            ),
            options=BlastMmsOptions(
                validate=True,
            ),
        )
        """
        _response = self._raw_client.mms(
            audience_id=audience_id, senders=senders, message=message, options=options, request_options=request_options
        )
        return _response.data

    def rcs(
        self,
        *,
        audience_id: str,
        senders: typing.Sequence[str],
        message: RcsValidateContent,
        options: typing.Optional[BlastRcsOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BlastRcsResponse:
        """
        Send an RCS message to all contacts in an audience. <br>

        Messages are distributed evenly across the provided RCS agents for load balancing. Requires active RCS agents and recipient devices that support RCS Business Messaging. <br>

        Use the optional `schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.

        Parameters
        ----------
        audience_id : str
            The audience ID to send the blast to. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. <br>

            You can create an audience via [the dashboard](https://app.pinnacle.sh/dashboard/audiences) or [API](/api-reference/audiences/create).

        senders : typing.Sequence[str]
            Array of RCS agent IDs to send from. Each must be prefixed with `agent_`. <br>

            Messages will be evenly distributed across these agents.

            > **Note:** Test agents cannot be used for blasts.

            **Limit:** 1 min

        message : RcsValidateContent

        options : typing.Optional[BlastRcsOptions]
            Configure how your RCS blast is sent and tracked.

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

        Returns
        -------
        BlastRcsResponse
            Successfully queued or scheduled the RCS blast. <br>

            - **Immediate blast**: Returns blast details including total recipients, messages, segments, and cost.
            - **Scheduled blast**: Returns a `scheduleId` and the schedule configuration.

        Examples
        --------
        from rcs import Pinnacle, RichButton_Trigger, RichText
        from rcs.messages.blast import BlastRcsOptions

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.blast.rcs(
            audience_id="aud_abc123",
            senders=["agent_pinnacle", "agent_pinnacle2"],
            message=RichText(
                quick_replies=[
                    RichButton_Trigger(
                        payload="payload",
                        title="title",
                    )
                ],
                text="Hello from Pinnacle RCS!",
            ),
            options=BlastRcsOptions(
                transcode=True,
                validate=True,
            ),
        )
        """
        _response = self._raw_client.rcs(
            audience_id=audience_id, senders=senders, message=message, options=options, request_options=request_options
        )
        return _response.data


class AsyncBlastClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBlastClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBlastClient
        """
        return self._raw_client

    async def sms(
        self,
        *,
        audience_id: str,
        senders: typing.Sequence[str],
        message: SmsContent,
        options: typing.Optional[BlastSmsOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BlastSmsResponse:
        """
        Send an SMS message to all contacts in an audience. <br>

        Messages are distributed evenly across the provided sender phone numbers. <br>

        Use the optional `schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.

        Parameters
        ----------
        audience_id : str
            The audience ID to send the blast to. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. <br>

            You can create an audience via [the dashboard](https://app.pinnacle.sh/dashboard/audiences) or [API](/api-reference/audiences/create).

        senders : typing.Sequence[str]
            Array of phone numbers to send from in E.164 format. <br>

            Messages will be distributed evenly across these senders.

            > **Note:** Sandbox numbers cannot be used for blasts.

            **Limit:** 1 min

        message : SmsContent

        options : typing.Optional[BlastSmsOptions]
            Additional settings to customize SMS blast delivery.

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

        Returns
        -------
        BlastSmsResponse
            Successfully queued or scheduled the SMS blast. <br>

            - **Immediate blast**: Returns blast details including total recipients, messages, segments, and cost.
            - **Scheduled blast**: Returns a `scheduleId` and the schedule configuration.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle, SmsContent

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.blast.sms(
                audience_id="aud_abc123",
                senders=["+14155164736", "+14155164737"],
                message=SmsContent(
                    text="Hello from Pinnacle!",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.sms(
            audience_id=audience_id, senders=senders, message=message, options=options, request_options=request_options
        )
        return _response.data

    async def mms(
        self,
        *,
        audience_id: str,
        senders: typing.Sequence[str],
        message: MmsContent,
        options: typing.Optional[BlastMmsOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BlastMmsResponse:
        """
        Send an MMS message to all contacts in an audience. <br>

        Messages are distributed evenly across the provided sender phone numbers. <br>

        Use the optional `schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.

        Parameters
        ----------
        audience_id : str
            The audience ID to send the blast to. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. <br>

            You can create an audience via [the dashboard](https://app.pinnacle.sh/dashboard/audiences) or [API](/api-reference/audiences/create).

        senders : typing.Sequence[str]
            Array of phone numbers to send from in E.164 format. <br>

            Messages will be distributed evenly across these senders.

            > **Note:** Sandbox numbers cannot be used for blasts.

            **Limit:** 1 min

        message : MmsContent

        options : typing.Optional[BlastMmsOptions]
            Additional settings to customize MMS blast delivery.

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

        Returns
        -------
        BlastMmsResponse
            Successfully queued or scheduled the MMS blast. <br>

            - **Immediate blast**: Returns blast details including total recipients, messages, segments, and cost.
            - **Scheduled blast**: Returns a `scheduleId` and the schedule configuration.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle, MmsContent
        from rcs.messages.blast import BlastMmsOptions

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.blast.mms(
                audience_id="aud_abc123",
                senders=["+14155164736", "+14155164737"],
                message=MmsContent(
                    media_urls=["https://fastly.picsum.photos/id/941/300/300.jpg"],
                    text="Check out this image!",
                ),
                options=BlastMmsOptions(
                    validate=True,
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.mms(
            audience_id=audience_id, senders=senders, message=message, options=options, request_options=request_options
        )
        return _response.data

    async def rcs(
        self,
        *,
        audience_id: str,
        senders: typing.Sequence[str],
        message: RcsValidateContent,
        options: typing.Optional[BlastRcsOptions] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BlastRcsResponse:
        """
        Send an RCS message to all contacts in an audience. <br>

        Messages are distributed evenly across the provided RCS agents for load balancing. Requires active RCS agents and recipient devices that support RCS Business Messaging. <br>

        Use the optional `schedule` parameter in `options` to schedule the blast for future delivery. When scheduled, the response will contain a `scheduleId` instead of blast details.

        Parameters
        ----------
        audience_id : str
            The audience ID to send the blast to. This identifier is a string that always begins with the prefix `aud_`, for example: `aud_abc123`. <br>

            You can create an audience via [the dashboard](https://app.pinnacle.sh/dashboard/audiences) or [API](/api-reference/audiences/create).

        senders : typing.Sequence[str]
            Array of RCS agent IDs to send from. Each must be prefixed with `agent_`. <br>

            Messages will be evenly distributed across these agents.

            > **Note:** Test agents cannot be used for blasts.

            **Limit:** 1 min

        message : RcsValidateContent

        options : typing.Optional[BlastRcsOptions]
            Configure how your RCS blast is sent and tracked.

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

        Returns
        -------
        BlastRcsResponse
            Successfully queued or scheduled the RCS blast. <br>

            - **Immediate blast**: Returns blast details including total recipients, messages, segments, and cost.
            - **Scheduled blast**: Returns a `scheduleId` and the schedule configuration.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle, RichButton_Trigger, RichText
        from rcs.messages.blast import BlastRcsOptions

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.blast.rcs(
                audience_id="aud_abc123",
                senders=["agent_pinnacle", "agent_pinnacle2"],
                message=RichText(
                    quick_replies=[
                        RichButton_Trigger(
                            payload="payload",
                            title="title",
                        )
                    ],
                    text="Hello from Pinnacle RCS!",
                ),
                options=BlastRcsOptions(
                    transcode=True,
                    validate=True,
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.rcs(
            audience_id=audience_id, senders=senders, message=message, options=options, request_options=request_options
        )
        return _response.data
