# 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.languages import Languages
from ..types.orchestrator_pipeline_result import OrchestratorPipelineResult
from .raw_client import AsyncRawStoryClient, RawStoryClient
from .types.create_story_story_post_response import CreateStoryStoryPostResponse
from .types.setup_story_story_setup_post_response import SetupStoryStorySetupPostResponse

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


class StoryClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawStoryClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawStoryClient
        """
        return self._raw_client

    def create_story(
        self,
        *,
        file: core.File,
        source_language: Languages,
        run_id: typing.Optional[int] = None,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        narrator_voice_id: typing.Optional[int] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        chosen_dictionaries: typing.Optional[typing.List[int]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateStoryStoryPostResponse:
        """
        Parameters
        ----------
        file : core.File
            See core.File for more documentation

        source_language : Languages

        run_id : typing.Optional[int]

        title : typing.Optional[str]

        description : typing.Optional[str]

        narrator_voice_id : typing.Optional[int]

        folder_id : typing.Optional[int]

        chosen_dictionaries : typing.Optional[typing.List[int]]

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

        Returns
        -------
        CreateStoryStoryPostResponse
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.story.create_story(
            source_language=1,
        )
        """
        _response = self._raw_client.create_story(
            file=file,
            source_language=source_language,
            run_id=run_id,
            title=title,
            description=description,
            narrator_voice_id=narrator_voice_id,
            folder_id=folder_id,
            chosen_dictionaries=chosen_dictionaries,
            request_options=request_options,
        )
        return _response.data

    def setup_story(
        self,
        *,
        file: core.File,
        source_language: Languages,
        run_id: typing.Optional[int] = None,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        narrator_voice_id: typing.Optional[int] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        chosen_dictionaries: typing.Optional[typing.List[int]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SetupStoryStorySetupPostResponse:
        """
        Parameters
        ----------
        file : core.File
            See core.File for more documentation

        source_language : Languages

        run_id : typing.Optional[int]

        title : typing.Optional[str]

        description : typing.Optional[str]

        narrator_voice_id : typing.Optional[int]

        folder_id : typing.Optional[int]

        chosen_dictionaries : typing.Optional[typing.List[int]]

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

        Returns
        -------
        SetupStoryStorySetupPostResponse
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.story.setup_story(
            source_language=1,
        )
        """
        _response = self._raw_client.setup_story(
            file=file,
            source_language=source_language,
            run_id=run_id,
            title=title,
            description=description,
            narrator_voice_id=narrator_voice_id,
            folder_id=folder_id,
            chosen_dictionaries=chosen_dictionaries,
            request_options=request_options,
        )
        return _response.data

    def get_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.story.get_story_status(
            task_id="task_id",
        )
        """
        _response = self._raw_client.get_story_status(task_id, run_id=run_id, request_options=request_options)
        return _response.data

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

        include_transcript : typing.Optional[bool]
            Whether to include the transcription in the response for fetching the result of a Stories 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.story.get_story_run_info(
            run_id=1,
        )
        """
        _response = self._raw_client.get_story_run_info(
            run_id, include_transcript=include_transcript, request_options=request_options
        )
        return _response.data

    def get_stories_runs_results(
        self,
        *,
        run_ids: typing.Sequence[int],
        run_id: typing.Optional[int] = None,
        traceparent: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Dict[str, typing.Any]]:
        """
        Parameters
        ----------
        run_ids : typing.Sequence[int]

        run_id : typing.Optional[int]

        traceparent : typing.Optional[str]

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

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

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.story.get_stories_runs_results(
            run_ids=[1],
        )
        """
        _response = self._raw_client.get_stories_runs_results(
            run_ids=run_ids, run_id=run_id, traceparent=traceparent, request_options=request_options
        )
        return _response.data


class AsyncStoryClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawStoryClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawStoryClient
        """
        return self._raw_client

    async def create_story(
        self,
        *,
        file: core.File,
        source_language: Languages,
        run_id: typing.Optional[int] = None,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        narrator_voice_id: typing.Optional[int] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        chosen_dictionaries: typing.Optional[typing.List[int]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateStoryStoryPostResponse:
        """
        Parameters
        ----------
        file : core.File
            See core.File for more documentation

        source_language : Languages

        run_id : typing.Optional[int]

        title : typing.Optional[str]

        description : typing.Optional[str]

        narrator_voice_id : typing.Optional[int]

        folder_id : typing.Optional[int]

        chosen_dictionaries : typing.Optional[typing.List[int]]

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

        Returns
        -------
        CreateStoryStoryPostResponse
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.story.create_story(
                source_language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_story(
            file=file,
            source_language=source_language,
            run_id=run_id,
            title=title,
            description=description,
            narrator_voice_id=narrator_voice_id,
            folder_id=folder_id,
            chosen_dictionaries=chosen_dictionaries,
            request_options=request_options,
        )
        return _response.data

    async def setup_story(
        self,
        *,
        file: core.File,
        source_language: Languages,
        run_id: typing.Optional[int] = None,
        title: typing.Optional[str] = OMIT,
        description: typing.Optional[str] = OMIT,
        narrator_voice_id: typing.Optional[int] = OMIT,
        folder_id: typing.Optional[int] = OMIT,
        chosen_dictionaries: typing.Optional[typing.List[int]] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SetupStoryStorySetupPostResponse:
        """
        Parameters
        ----------
        file : core.File
            See core.File for more documentation

        source_language : Languages

        run_id : typing.Optional[int]

        title : typing.Optional[str]

        description : typing.Optional[str]

        narrator_voice_id : typing.Optional[int]

        folder_id : typing.Optional[int]

        chosen_dictionaries : typing.Optional[typing.List[int]]

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

        Returns
        -------
        SetupStoryStorySetupPostResponse
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.story.setup_story(
                source_language=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.setup_story(
            file=file,
            source_language=source_language,
            run_id=run_id,
            title=title,
            description=description,
            narrator_voice_id=narrator_voice_id,
            folder_id=folder_id,
            chosen_dictionaries=chosen_dictionaries,
            request_options=request_options,
        )
        return _response.data

    async def get_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.story.get_story_status(
                task_id="task_id",
            )


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

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

        include_transcript : typing.Optional[bool]
            Whether to include the transcription in the response for fetching the result of a Stories 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.story.get_story_run_info(
                run_id=1,
            )


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

    async def get_stories_runs_results(
        self,
        *,
        run_ids: typing.Sequence[int],
        run_id: typing.Optional[int] = None,
        traceparent: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Dict[str, typing.Dict[str, typing.Any]]:
        """
        Parameters
        ----------
        run_ids : typing.Sequence[int]

        run_id : typing.Optional[int]

        traceparent : typing.Optional[str]

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

        Returns
        -------
        typing.Dict[str, 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.story.get_stories_runs_results(
                run_ids=[1],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_stories_runs_results(
            run_ids=run_ids, run_id=run_id, traceparent=traceparent, request_options=request_options
        )
        return _response.data
