# 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 .raw_client import AsyncRawCallsClient, RawCallsClient
from .types.post_conversation_outbound_response import PostConversationOutboundResponse

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


class CallsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCallsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCallsClient
        """
        return self._raw_client

    def start_an_outbound_call(
        self,
        *,
        agent_id: str,
        phone_number: str,
        variables: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        from_product_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostConversationOutboundResponse:
        """
        Initiates an outbound conversation with a specified agent and phone number.

        Parameters
        ----------
        agent_id : str
            The ID of the agent initiating the conversation

        phone_number : str
            The phone number to call

        variables : typing.Optional[typing.Dict[str, typing.Any]]
            The variables to pass to the conversation

        from_product_id : typing.Optional[str]
            The ID of the product to use for the call (get this from the /product/phone-numbers endpoint)

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

        Returns
        -------
        PostConversationOutboundResponse
            Successfully started the outbound conversation

        Examples
        --------
        from smallestai import SmallestAI

        client = SmallestAI(
            token="YOUR_TOKEN",
        )
        client.atoms.calls.start_an_outbound_call(
            agent_id="60d0fe4f5311236168a109ca",
            phone_number="+1234567890",
        )
        """
        _response = self._raw_client.start_an_outbound_call(
            agent_id=agent_id,
            phone_number=phone_number,
            variables=variables,
            from_product_id=from_product_id,
            request_options=request_options,
        )
        return _response.data


class AsyncCallsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCallsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCallsClient
        """
        return self._raw_client

    async def start_an_outbound_call(
        self,
        *,
        agent_id: str,
        phone_number: str,
        variables: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
        from_product_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PostConversationOutboundResponse:
        """
        Initiates an outbound conversation with a specified agent and phone number.

        Parameters
        ----------
        agent_id : str
            The ID of the agent initiating the conversation

        phone_number : str
            The phone number to call

        variables : typing.Optional[typing.Dict[str, typing.Any]]
            The variables to pass to the conversation

        from_product_id : typing.Optional[str]
            The ID of the product to use for the call (get this from the /product/phone-numbers endpoint)

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

        Returns
        -------
        PostConversationOutboundResponse
            Successfully started the outbound conversation

        Examples
        --------
        import asyncio

        from smallestai import AsyncSmallestAI

        client = AsyncSmallestAI(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.atoms.calls.start_an_outbound_call(
                agent_id="60d0fe4f5311236168a109ca",
                phone_number="+1234567890",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.start_an_outbound_call(
            agent_id=agent_id,
            phone_number=phone_number,
            variables=variables,
            from_product_id=from_product_id,
            request_options=request_options,
        )
        return _response.data
