# 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.exotel_outbound_call_response import ExotelOutboundCallResponse
from ...types.telephony_call_config import TelephonyCallConfig
from .raw_client import AsyncRawExotelClient, RawExotelClient

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


class ExotelClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawExotelClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawExotelClient
        """
        return self._raw_client

    def outbound_call(
        self,
        *,
        agent_id: str,
        agent_phone_number_id: str,
        to_number: str,
        conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT,
        telephony_call_config: typing.Optional[TelephonyCallConfig] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ExotelOutboundCallResponse:
        """
        Handle an outbound call via Exotel Connect API

        Parameters
        ----------
        agent_id : str

        agent_phone_number_id : str

        to_number : str

        conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput]

        telephony_call_config : typing.Optional[TelephonyCallConfig]

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

        Returns
        -------
        ExotelOutboundCallResponse
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.exotel.outbound_call(
            agent_id="agent_id",
            agent_phone_number_id="agent_phone_number_id",
            to_number="to_number",
        )
        """
        _response = self._raw_client.outbound_call(
            agent_id=agent_id,
            agent_phone_number_id=agent_phone_number_id,
            to_number=to_number,
            conversation_initiation_client_data=conversation_initiation_client_data,
            telephony_call_config=telephony_call_config,
            request_options=request_options,
        )
        return _response.data


class AsyncExotelClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawExotelClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawExotelClient
        """
        return self._raw_client

    async def outbound_call(
        self,
        *,
        agent_id: str,
        agent_phone_number_id: str,
        to_number: str,
        conversation_initiation_client_data: typing.Optional[ConversationInitiationClientDataRequestInput] = OMIT,
        telephony_call_config: typing.Optional[TelephonyCallConfig] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ExotelOutboundCallResponse:
        """
        Handle an outbound call via Exotel Connect API

        Parameters
        ----------
        agent_id : str

        agent_phone_number_id : str

        to_number : str

        conversation_initiation_client_data : typing.Optional[ConversationInitiationClientDataRequestInput]

        telephony_call_config : typing.Optional[TelephonyCallConfig]

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

        Returns
        -------
        ExotelOutboundCallResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.exotel.outbound_call(
                agent_id="agent_id",
                agent_phone_number_id="agent_phone_number_id",
                to_number="to_number",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.outbound_call(
            agent_id=agent_id,
            agent_phone_number_id=agent_phone_number_id,
            to_number=to_number,
            conversation_initiation_client_data=conversation_initiation_client_data,
            telephony_call_config=telephony_call_config,
            request_options=request_options,
        )
        return _response.data
