# 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.conversation_initiation_client_data_request_input import ConversationInitiationClientDataRequestInput
from ...types.whats_app_outbound_call_response import WhatsAppOutboundCallResponse
from ...types.whats_app_outbound_message_response import WhatsAppOutboundMessageResponse
from .raw_client import AsyncRawWhatsappClient, RawWhatsappClient
from .types.body_send_an_outbound_message_via_whats_app_v_1_convai_whatsapp_outbound_message_post_template_params_item import (
    BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem,
)

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


class WhatsappClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWhatsappClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawWhatsappClient
        """
        return self._raw_client

    def outbound_call(
        self,
        *,
        whatsapp_phone_number_id: str,
        whatsapp_user_id: str,
        whatsapp_call_permission_request_template_name: str,
        whatsapp_call_permission_request_template_language_code: str,
        agent_id: str,
        conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WhatsAppOutboundCallResponse:
        """
        Make an outbound call via WhatsApp

        Parameters
        ----------
        whatsapp_phone_number_id : str

        whatsapp_user_id : str

        whatsapp_call_permission_request_template_name : str

        whatsapp_call_permission_request_template_language_code : str

        agent_id : str

        conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput]

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

        Returns
        -------
        WhatsAppOutboundCallResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.whatsapp.outbound_call(
            whatsapp_phone_number_id="whatsapp_phone_number_id",
            whatsapp_user_id="whatsapp_user_id",
            whatsapp_call_permission_request_template_name="whatsapp_call_permission_request_template_name",
            whatsapp_call_permission_request_template_language_code="whatsapp_call_permission_request_template_language_code",
            agent_id="agent_id",
        )
        """
        _response = self._raw_client.outbound_call(
            whatsapp_phone_number_id=whatsapp_phone_number_id,
            whatsapp_user_id=whatsapp_user_id,
            whatsapp_call_permission_request_template_name=whatsapp_call_permission_request_template_name,
            whatsapp_call_permission_request_template_language_code=whatsapp_call_permission_request_template_language_code,
            agent_id=agent_id,
            conversation_initiation_client_data=conversation_initiation_client_data,
            request_options=request_options,
        )
        return _response.data

    def outbound_message(
        self,
        *,
        whatsapp_phone_number_id: str,
        whatsapp_user_id: str,
        template_name: str,
        template_language_code: str,
        template_params: typing.Sequence[
            BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem
        ],
        agent_id: str,
        conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WhatsAppOutboundMessageResponse:
        """
        Send an outbound message via WhatsApp

        Parameters
        ----------
        whatsapp_phone_number_id : str

        whatsapp_user_id : str

        template_name : str

        template_language_code : str

        template_params : typing.Sequence[BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem]

        agent_id : str

        conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput]

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

        Returns
        -------
        WhatsAppOutboundMessageResponse
            Successful Response

        Examples
        --------
        from elevenlabs import ElevenLabs, WhatsAppTemplateTextParam
        from elevenlabs.conversational_ai.whatsapp import (
            BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem_Body,
        )

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.whatsapp.outbound_message(
            whatsapp_phone_number_id="whatsapp_phone_number_id",
            whatsapp_user_id="whatsapp_user_id",
            template_name="template_name",
            template_language_code="template_language_code",
            template_params=[
                BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem_Body(
                    parameters=[
                        WhatsAppTemplateTextParam(
                            text="text",
                        )
                    ],
                )
            ],
            agent_id="agent_id",
        )
        """
        _response = self._raw_client.outbound_message(
            whatsapp_phone_number_id=whatsapp_phone_number_id,
            whatsapp_user_id=whatsapp_user_id,
            template_name=template_name,
            template_language_code=template_language_code,
            template_params=template_params,
            agent_id=agent_id,
            conversation_initiation_client_data=conversation_initiation_client_data,
            request_options=request_options,
        )
        return _response.data


class AsyncWhatsappClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWhatsappClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawWhatsappClient
        """
        return self._raw_client

    async def outbound_call(
        self,
        *,
        whatsapp_phone_number_id: str,
        whatsapp_user_id: str,
        whatsapp_call_permission_request_template_name: str,
        whatsapp_call_permission_request_template_language_code: str,
        agent_id: str,
        conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WhatsAppOutboundCallResponse:
        """
        Make an outbound call via WhatsApp

        Parameters
        ----------
        whatsapp_phone_number_id : str

        whatsapp_user_id : str

        whatsapp_call_permission_request_template_name : str

        whatsapp_call_permission_request_template_language_code : str

        agent_id : str

        conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput]

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

        Returns
        -------
        WhatsAppOutboundCallResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.whatsapp.outbound_call(
                whatsapp_phone_number_id="whatsapp_phone_number_id",
                whatsapp_user_id="whatsapp_user_id",
                whatsapp_call_permission_request_template_name="whatsapp_call_permission_request_template_name",
                whatsapp_call_permission_request_template_language_code="whatsapp_call_permission_request_template_language_code",
                agent_id="agent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.outbound_call(
            whatsapp_phone_number_id=whatsapp_phone_number_id,
            whatsapp_user_id=whatsapp_user_id,
            whatsapp_call_permission_request_template_name=whatsapp_call_permission_request_template_name,
            whatsapp_call_permission_request_template_language_code=whatsapp_call_permission_request_template_language_code,
            agent_id=agent_id,
            conversation_initiation_client_data=conversation_initiation_client_data,
            request_options=request_options,
        )
        return _response.data

    async def outbound_message(
        self,
        *,
        whatsapp_phone_number_id: str,
        whatsapp_user_id: str,
        template_name: str,
        template_language_code: str,
        template_params: typing.Sequence[
            BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem
        ],
        agent_id: str,
        conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> WhatsAppOutboundMessageResponse:
        """
        Send an outbound message via WhatsApp

        Parameters
        ----------
        whatsapp_phone_number_id : str

        whatsapp_user_id : str

        template_name : str

        template_language_code : str

        template_params : typing.Sequence[BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem]

        agent_id : str

        conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput]

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

        Returns
        -------
        WhatsAppOutboundMessageResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs, WhatsAppTemplateTextParam
        from elevenlabs.conversational_ai.whatsapp import (
            BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem_Body,
        )

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.whatsapp.outbound_message(
                whatsapp_phone_number_id="whatsapp_phone_number_id",
                whatsapp_user_id="whatsapp_user_id",
                template_name="template_name",
                template_language_code="template_language_code",
                template_params=[
                    BodySendAnOutboundMessageViaWhatsAppV1ConvaiWhatsappOutboundMessagePostTemplateParamsItem_Body(
                        parameters=[
                            WhatsAppTemplateTextParam(
                                text="text",
                            )
                        ],
                    )
                ],
                agent_id="agent_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.outbound_message(
            whatsapp_phone_number_id=whatsapp_phone_number_id,
            whatsapp_user_id=whatsapp_user_id,
            template_name=template_name,
            template_language_code=template_language_code,
            template_params=template_params,
            agent_id=agent_id,
            conversation_initiation_client_data=conversation_initiation_client_data,
            request_options=request_options,
        )
        return _response.data
