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

import typing

from .... import core
from ....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ....core.request_options import RequestOptions
from ....types.conv_ai_file_upload_response_model import ConvAiFileUploadResponseModel
from .raw_client import AsyncRawFilesClient, RawFilesClient

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


class FilesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawFilesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawFilesClient
        """
        return self._raw_client

    def create(
        self, conversation_id: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvAiFileUploadResponseModel:
        """
        Upload an image or PDF file for a conversation. Returns a unique file ID that can be used to reference the file in the conversation.

        Parameters
        ----------
        conversation_id : str

        file : core.File
            See core.File for more documentation

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

        Returns
        -------
        ConvAiFileUploadResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.files.create(
            conversation_id="conversation_id",
        )
        """
        _response = self._raw_client.create(conversation_id, file=file, request_options=request_options)
        return _response.data

    def delete(
        self, conversation_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvAiFileUploadResponseModel:
        """
        Remove a file upload from a conversation. Only possible if the file hasn't already been used in the conversation.

        Parameters
        ----------
        conversation_id : str

        file_id : str

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

        Returns
        -------
        ConvAiFileUploadResponseModel
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.conversational_ai.conversations.files.delete(
            conversation_id="conversation_id",
            file_id="file_id",
        )
        """
        _response = self._raw_client.delete(conversation_id, file_id, request_options=request_options)
        return _response.data


class AsyncFilesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawFilesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawFilesClient
        """
        return self._raw_client

    async def create(
        self, conversation_id: str, *, file: core.File, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvAiFileUploadResponseModel:
        """
        Upload an image or PDF file for a conversation. Returns a unique file ID that can be used to reference the file in the conversation.

        Parameters
        ----------
        conversation_id : str

        file : core.File
            See core.File for more documentation

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

        Returns
        -------
        ConvAiFileUploadResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.files.create(
                conversation_id="conversation_id",
            )


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

    async def delete(
        self, conversation_id: str, file_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> ConvAiFileUploadResponseModel:
        """
        Remove a file upload from a conversation. Only possible if the file hasn't already been used in the conversation.

        Parameters
        ----------
        conversation_id : str

        file_id : str

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

        Returns
        -------
        ConvAiFileUploadResponseModel
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.conversational_ai.conversations.files.delete(
                conversation_id="conversation_id",
                file_id="file_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(conversation_id, file_id, request_options=request_options)
        return _response.data
