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

from __future__ import annotations

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from ..types.rcs_agent_response import RcsAgentResponse
from ..types.rcs_capabilities_result import RcsCapabilitiesResult
from ..types.rcs_link_result import RcsLinkResult
from .raw_client import AsyncRawRcsClient, RawRcsClient

if typing.TYPE_CHECKING:
    from .agents.client import AgentsClient, AsyncAgentsClient
    from .test.client import AsyncTestClient, TestClient
    from .whitelisted_numbers.client import AsyncWhitelistedNumbersClient, WhitelistedNumbersClient
# 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)
        self._client_wrapper = client_wrapper
        self._agents: typing.Optional[AgentsClient] = None
        self._whitelisted_numbers: typing.Optional[WhitelistedNumbersClient] = None
        self._test: typing.Optional[TestClient] = None

    @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 get_agent(self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RcsAgentResponse:
        """
        Retrieve details of an RCS agent by its ID.

        Returns the agent's configuration including display name, description, logo, hero image,
        contact information, and other settings.

        Parameters
        ----------
        agent_id : str
            The RCS agent ID (must be prefixed with `agent_`).

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

        Returns
        -------
        RcsAgentResponse
            The agent details.

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.rcs.get_agent(
            agent_id="agent_abc123def456",
        )
        """
        _response = self._raw_client.get_agent(agent_id, request_options=request_options)
        return _response.data

    def get_capabilities(
        self,
        *,
        phone_numbers: typing.Sequence[str],
        agent_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RcsCapabilitiesResult:
        """
        Check RCS capabilities for one or more phone numbers.

        This endpoint allows you to verify which RCS features (cards, buttons, etc.) are supported
        on specific phone numbers before sending RCS messages to them.

        Parameters
        ----------
        phone_numbers : typing.Sequence[str]
            List of phone numbers to check RCS capabilities for (E.164 format). <br><br>
            **Limit:** 1 min

        agent_id : typing.Optional[str]
            Optional RCS agent ID (prefixed with 'agent_') to check capabilities of a number from a specific agent.

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

        Returns
        -------
        RcsCapabilitiesResult
            Returns RCS capabilities for each requested phone number.

            The response is a map where keys are phone numbers and values are either:
            - `null` if the number doesn't support RCS
            - An object containing supported cards and actions if RCS is supported

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.rcs.get_capabilities(
            phone_numbers=["+12345678901", "+19876543210"],
        )
        """
        _response = self._raw_client.get_capabilities(
            phone_numbers=phone_numbers, agent_id=agent_id, request_options=request_options
        )
        return _response.data

    def get_link(
        self,
        *,
        agent_id: str,
        phone_number: typing.Optional[str] = OMIT,
        body: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RcsLinkResult:
        """
        Generate a link for initiating an RCS conversation with your agent.

        Users can click these links to start conversations with your RCS agent directly
        from websites, emails, or other applications.

        Parameters
        ----------
        agent_id : str
            The RCS agent ID (must be prefixed with 'agent_')

        phone_number : typing.Optional[str]
            Fallback phone number (E.164 format) to use if the phone number does not support RCS. If not provided, no url will be generated.

        body : typing.Optional[str]
            Optional message body to pre-fill after the user clicks the link

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

        Returns
        -------
        RcsLinkResult
            Response containing the generated RCS service id and/or url.

            You can always create a link with the service id that is returned using the format:
            ```
            sms://{PHONE_NUMBER}?service_id={SERVICE_ID}&body={URL_ENCODED_BODY}
            ```

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.rcs.get_link(
            agent_id="agent_XXXXXXXXXXXX",
            phone_number="+12345678901",
            body="Hello, I need help with my order",
        )
        """
        _response = self._raw_client.get_link(
            agent_id=agent_id, phone_number=phone_number, body=body, request_options=request_options
        )
        return _response.data

    @property
    def agents(self):
        if self._agents is None:
            from .agents.client import AgentsClient  # noqa: E402

            self._agents = AgentsClient(client_wrapper=self._client_wrapper)
        return self._agents

    @property
    def whitelisted_numbers(self):
        if self._whitelisted_numbers is None:
            from .whitelisted_numbers.client import WhitelistedNumbersClient  # noqa: E402

            self._whitelisted_numbers = WhitelistedNumbersClient(client_wrapper=self._client_wrapper)
        return self._whitelisted_numbers

    @property
    def test(self):
        if self._test is None:
            from .test.client import TestClient  # noqa: E402

            self._test = TestClient(client_wrapper=self._client_wrapper)
        return self._test


class AsyncRcsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawRcsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._agents: typing.Optional[AsyncAgentsClient] = None
        self._whitelisted_numbers: typing.Optional[AsyncWhitelistedNumbersClient] = None
        self._test: typing.Optional[AsyncTestClient] = None

    @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 get_agent(
        self, agent_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RcsAgentResponse:
        """
        Retrieve details of an RCS agent by its ID.

        Returns the agent's configuration including display name, description, logo, hero image,
        contact information, and other settings.

        Parameters
        ----------
        agent_id : str
            The RCS agent ID (must be prefixed with `agent_`).

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

        Returns
        -------
        RcsAgentResponse
            The agent details.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.rcs.get_agent(
                agent_id="agent_abc123def456",
            )


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

    async def get_capabilities(
        self,
        *,
        phone_numbers: typing.Sequence[str],
        agent_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RcsCapabilitiesResult:
        """
        Check RCS capabilities for one or more phone numbers.

        This endpoint allows you to verify which RCS features (cards, buttons, etc.) are supported
        on specific phone numbers before sending RCS messages to them.

        Parameters
        ----------
        phone_numbers : typing.Sequence[str]
            List of phone numbers to check RCS capabilities for (E.164 format). <br><br>
            **Limit:** 1 min

        agent_id : typing.Optional[str]
            Optional RCS agent ID (prefixed with 'agent_') to check capabilities of a number from a specific agent.

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

        Returns
        -------
        RcsCapabilitiesResult
            Returns RCS capabilities for each requested phone number.

            The response is a map where keys are phone numbers and values are either:
            - `null` if the number doesn't support RCS
            - An object containing supported cards and actions if RCS is supported

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.rcs.get_capabilities(
                phone_numbers=["+12345678901", "+19876543210"],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_capabilities(
            phone_numbers=phone_numbers, agent_id=agent_id, request_options=request_options
        )
        return _response.data

    async def get_link(
        self,
        *,
        agent_id: str,
        phone_number: typing.Optional[str] = OMIT,
        body: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RcsLinkResult:
        """
        Generate a link for initiating an RCS conversation with your agent.

        Users can click these links to start conversations with your RCS agent directly
        from websites, emails, or other applications.

        Parameters
        ----------
        agent_id : str
            The RCS agent ID (must be prefixed with 'agent_')

        phone_number : typing.Optional[str]
            Fallback phone number (E.164 format) to use if the phone number does not support RCS. If not provided, no url will be generated.

        body : typing.Optional[str]
            Optional message body to pre-fill after the user clicks the link

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

        Returns
        -------
        RcsLinkResult
            Response containing the generated RCS service id and/or url.

            You can always create a link with the service id that is returned using the format:
            ```
            sms://{PHONE_NUMBER}?service_id={SERVICE_ID}&body={URL_ENCODED_BODY}
            ```

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.rcs.get_link(
                agent_id="agent_XXXXXXXXXXXX",
                phone_number="+12345678901",
                body="Hello, I need help with my order",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_link(
            agent_id=agent_id, phone_number=phone_number, body=body, request_options=request_options
        )
        return _response.data

    @property
    def agents(self):
        if self._agents is None:
            from .agents.client import AsyncAgentsClient  # noqa: E402

            self._agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
        return self._agents

    @property
    def whitelisted_numbers(self):
        if self._whitelisted_numbers is None:
            from .whitelisted_numbers.client import AsyncWhitelistedNumbersClient  # noqa: E402

            self._whitelisted_numbers = AsyncWhitelistedNumbersClient(client_wrapper=self._client_wrapper)
        return self._whitelisted_numbers

    @property
    def test(self):
        if self._test is None:
            from .test.client import AsyncTestClient  # noqa: E402

            self._test = AsyncTestClient(client_wrapper=self._client_wrapper)
        return self._test
