# 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.single_use_token_response_model import SingleUseTokenResponseModel
from ...types.single_use_token_type import SingleUseTokenType
from .raw_client import AsyncRawSingleUseClient, RawSingleUseClient


class SingleUseClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSingleUseClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSingleUseClient
        """
        return self._raw_client

    def create(
        self, token_type: SingleUseTokenType, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SingleUseTokenResponseModel:
        """
        Generate a time limited single-use token with embedded authentication for frontend clients.

        Parameters
        ----------
        token_type : SingleUseTokenType

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

        Returns
        -------
        SingleUseTokenResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.tokens.single_use.create(
            token_type="realtime_scribe",
        )
        """
        _response = self._raw_client.create(token_type, request_options=request_options)
        return _response.data


class AsyncSingleUseClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSingleUseClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSingleUseClient
        """
        return self._raw_client

    async def create(
        self, token_type: SingleUseTokenType, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SingleUseTokenResponseModel:
        """
        Generate a time limited single-use token with embedded authentication for frontend clients.

        Parameters
        ----------
        token_type : SingleUseTokenType

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

        Returns
        -------
        SingleUseTokenResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.tokens.single_use.create(
                token_type="realtime_scribe",
            )


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