# 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.dictionary_with_terms import DictionaryWithTerms
from ..types.term_translation_input import TermTranslationInput
from .raw_client import AsyncRawDictionariesClient, RawDictionariesClient

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


class DictionariesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDictionariesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDictionariesClient
        """
        return self._raw_client

    def get_dictionaries(
        self, *, run_id: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[DictionaryWithTerms]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.List[DictionaryWithTerms]
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.get_dictionaries()
        """
        _response = self._raw_client.get_dictionaries(run_id=run_id, request_options=request_options)
        return _response.data

    def create_dictionary_from_file(
        self,
        *,
        dictionary_file: core.File,
        dictionary_name: str,
        run_id: typing.Optional[int] = None,
        dictionary_description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_file : core.File
            See core.File for more documentation

        dictionary_name : str
            The name of the dictonary to be created. This is mainly used for organizational purposes.

        run_id : typing.Optional[int]

        dictionary_description : typing.Optional[str]
            The description of the dictionary to be created. This is an optional field that is used to help you provide some info about your dictionaries for better organization.

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

        Returns
        -------
        typing.Any
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.create_dictionary_from_file(
            dictionary_name="dictionary_name",
        )
        """
        _response = self._raw_client.create_dictionary_from_file(
            dictionary_file=dictionary_file,
            dictionary_name=dictionary_name,
            run_id=run_id,
            dictionary_description=dictionary_description,
            request_options=request_options,
        )
        return _response.data

    def get_dictionary_info(
        self,
        dictionary_id: int,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DictionaryWithTerms:
        """
        Parameters
        ----------
        dictionary_id : int

        run_id : typing.Optional[int]

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

        Returns
        -------
        DictionaryWithTerms
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.get_dictionary_info(
            dictionary_id=1,
        )
        """
        _response = self._raw_client.get_dictionary_info(dictionary_id, run_id=run_id, request_options=request_options)
        return _response.data

    def delete_dictionary(
        self,
        dictionary_id: int,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.delete_dictionary(
            dictionary_id=1,
        )
        """
        _response = self._raw_client.delete_dictionary(dictionary_id, run_id=run_id, request_options=request_options)
        return _response.data

    def get_dictionary_details(
        self,
        dictionary_id: int,
        *,
        limit: typing.Optional[int] = None,
        search_term: typing.Optional[str] = None,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DictionaryWithTerms:
        """
        Parameters
        ----------
        dictionary_id : int

        limit : typing.Optional[int]
            Limit how many terms are returned when fetching the dictionary details.

        search_term : typing.Optional[str]

        run_id : typing.Optional[int]

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

        Returns
        -------
        DictionaryWithTerms
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.get_dictionary_details(
            dictionary_id=1,
        )
        """
        _response = self._raw_client.get_dictionary_details(
            dictionary_id, limit=limit, search_term=search_term, run_id=run_id, request_options=request_options
        )
        return _response.data

    def add_term_to_dictionary(
        self,
        dictionary_id: int,
        *,
        translations: typing.Sequence[TermTranslationInput],
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        translations : typing.Sequence[TermTranslationInput]

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from camb import CambApi, TermTranslationInput

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.add_term_to_dictionary(
            dictionary_id=1,
            translations=[
                TermTranslationInput(
                    translation="translation",
                    language=1,
                )
            ],
        )
        """
        _response = self._raw_client.add_term_to_dictionary(
            dictionary_id, translations=translations, run_id=run_id, request_options=request_options
        )
        return _response.data

    def update_term_translation_in_dictionary_using_term_id(
        self,
        dictionary_id: int,
        term_id: int,
        *,
        translations: typing.Sequence[TermTranslationInput],
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        term_id : int

        translations : typing.Sequence[TermTranslationInput]

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from camb import CambApi, TermTranslationInput

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.update_term_translation_in_dictionary_using_term_id(
            dictionary_id=1,
            term_id=1,
            translations=[
                TermTranslationInput(
                    translation="translation",
                    language=1,
                )
            ],
        )
        """
        _response = self._raw_client.update_term_translation_in_dictionary_using_term_id(
            dictionary_id, term_id, translations=translations, run_id=run_id, request_options=request_options
        )
        return _response.data

    def delete_dictionary_term(
        self,
        dictionary_id: int,
        term_id: int,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        term_id : int

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

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

        client = CambApi(
            api_key="YOUR_API_KEY",
        )
        client.dictionaries.delete_dictionary_term(
            dictionary_id=1,
            term_id=1,
        )
        """
        _response = self._raw_client.delete_dictionary_term(
            dictionary_id, term_id, run_id=run_id, request_options=request_options
        )
        return _response.data


class AsyncDictionariesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDictionariesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDictionariesClient
        """
        return self._raw_client

    async def get_dictionaries(
        self, *, run_id: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[DictionaryWithTerms]:
        """
        Parameters
        ----------
        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.List[DictionaryWithTerms]
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.get_dictionaries()


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

    async def create_dictionary_from_file(
        self,
        *,
        dictionary_file: core.File,
        dictionary_name: str,
        run_id: typing.Optional[int] = None,
        dictionary_description: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_file : core.File
            See core.File for more documentation

        dictionary_name : str
            The name of the dictonary to be created. This is mainly used for organizational purposes.

        run_id : typing.Optional[int]

        dictionary_description : typing.Optional[str]
            The description of the dictionary to be created. This is an optional field that is used to help you provide some info about your dictionaries for better organization.

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.create_dictionary_from_file(
                dictionary_name="dictionary_name",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create_dictionary_from_file(
            dictionary_file=dictionary_file,
            dictionary_name=dictionary_name,
            run_id=run_id,
            dictionary_description=dictionary_description,
            request_options=request_options,
        )
        return _response.data

    async def get_dictionary_info(
        self,
        dictionary_id: int,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DictionaryWithTerms:
        """
        Parameters
        ----------
        dictionary_id : int

        run_id : typing.Optional[int]

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

        Returns
        -------
        DictionaryWithTerms
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.get_dictionary_info(
                dictionary_id=1,
            )


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

    async def delete_dictionary(
        self,
        dictionary_id: int,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.delete_dictionary(
                dictionary_id=1,
            )


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

    async def get_dictionary_details(
        self,
        dictionary_id: int,
        *,
        limit: typing.Optional[int] = None,
        search_term: typing.Optional[str] = None,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DictionaryWithTerms:
        """
        Parameters
        ----------
        dictionary_id : int

        limit : typing.Optional[int]
            Limit how many terms are returned when fetching the dictionary details.

        search_term : typing.Optional[str]

        run_id : typing.Optional[int]

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

        Returns
        -------
        DictionaryWithTerms
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.get_dictionary_details(
                dictionary_id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_dictionary_details(
            dictionary_id, limit=limit, search_term=search_term, run_id=run_id, request_options=request_options
        )
        return _response.data

    async def add_term_to_dictionary(
        self,
        dictionary_id: int,
        *,
        translations: typing.Sequence[TermTranslationInput],
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        translations : typing.Sequence[TermTranslationInput]

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi, TermTranslationInput

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.add_term_to_dictionary(
                dictionary_id=1,
                translations=[
                    TermTranslationInput(
                        translation="translation",
                        language=1,
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.add_term_to_dictionary(
            dictionary_id, translations=translations, run_id=run_id, request_options=request_options
        )
        return _response.data

    async def update_term_translation_in_dictionary_using_term_id(
        self,
        dictionary_id: int,
        term_id: int,
        *,
        translations: typing.Sequence[TermTranslationInput],
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        term_id : int

        translations : typing.Sequence[TermTranslationInput]

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi, TermTranslationInput

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.update_term_translation_in_dictionary_using_term_id(
                dictionary_id=1,
                term_id=1,
                translations=[
                    TermTranslationInput(
                        translation="translation",
                        language=1,
                    )
                ],
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_term_translation_in_dictionary_using_term_id(
            dictionary_id, term_id, translations=translations, run_id=run_id, request_options=request_options
        )
        return _response.data

    async def delete_dictionary_term(
        self,
        dictionary_id: int,
        term_id: int,
        *,
        run_id: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Parameters
        ----------
        dictionary_id : int

        term_id : int

        run_id : typing.Optional[int]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from camb import AsyncCambApi

        client = AsyncCambApi(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.dictionaries.delete_dictionary_term(
                dictionary_id=1,
                term_id=1,
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete_dictionary_term(
            dictionary_id, term_id, run_id=run_id, request_options=request_options
        )
        return _response.data
