# 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.add_target_language_out import AddTargetLanguageOut
from ..types.languages import Languages
from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
from .raw_client import AsyncRawTranslatedStoryClient, RawTranslatedStoryClient

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


class TranslatedStoryClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawTranslatedStoryClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawTranslatedStoryClient
        """
        return self._raw_client

    def create_translation_for_existing_story(
        self,
        run_id: typing.Optional[int],
        *,
        target_language: Languages,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AddTargetLanguageOut:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        target_language : Languages

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

        Returns
        -------
        AddTargetLanguageOut
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.translated_story.create_translation_for_existing_story(
            run_id=1,
            target_language=1,
        )
        """
        _response = self._raw_client.create_translation_for_existing_story(
            run_id, target_language=target_language, request_options=request_options
        )
        return _response.data

    def get_translated_story_status(
        self,
        task_id: str,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineResult:
        """
        Parameters
        ----------
        task_id : str

        run_id : typing.Optional[int]

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

        Returns
        -------
        OrchestratorPipelineResult
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.translated_story.get_translated_story_status(
            task_id="task_id",
        )
        """
        _response = self._raw_client.get_translated_story_status(
            task_id, run_id=run_id, request_options=request_options
        )
        return _response.data

    def get_translated_story_run_info(
        self,
        run_id: typing.Optional[int],
        target_language: Languages,
        *,
        include_transcript: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        target_language : Languages

        include_transcript : typing.Optional[bool]
            Whether to include the transcription in the response for fetching the result of a Stories Translation run.

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        from camb import CambApi

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.translated_story.get_translated_story_run_info(
            run_id=1,
            target_language=1,
        )
        """
        _response = self._raw_client.get_translated_story_run_info(
            run_id, target_language, include_transcript=include_transcript, request_options=request_options
        )
        return _response.data


class AsyncTranslatedStoryClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawTranslatedStoryClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawTranslatedStoryClient
        """
        return self._raw_client

    async def create_translation_for_existing_story(
        self,
        run_id: typing.Optional[int],
        *,
        target_language: Languages,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AddTargetLanguageOut:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        target_language : Languages

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

        Returns
        -------
        AddTargetLanguageOut
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.translated_story.create_translation_for_existing_story(
                run_id=1,
                target_language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_translation_for_existing_story(
            run_id, target_language=target_language, request_options=request_options
        )
        return _response.data

    async def get_translated_story_status(
        self,
        task_id: str,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> OrchestratorPipelineResult:
        """
        Parameters
        ----------
        task_id : str

        run_id : typing.Optional[int]

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

        Returns
        -------
        OrchestratorPipelineResult
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.translated_story.get_translated_story_status(
                task_id="task_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_translated_story_status(
            task_id, run_id=run_id, request_options=request_options
        )
        return _response.data

    async def get_translated_story_run_info(
        self,
        run_id: typing.Optional[int],
        target_language: Languages,
        *,
        include_transcript: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Any]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

        target_language : Languages

        include_transcript : typing.Optional[bool]
            Whether to include the transcription in the response for fetching the result of a Stories Translation run.

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.translated_story.get_translated_story_run_info(
                run_id=1,
                target_language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_translated_story_run_info(
            run_id, target_language, include_transcript=include_transcript, request_options=request_options
        )
        return _response.data
