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

import typing
from ..core.client_wrapper import SyncClientWrapper
from ..core.request_options import RequestOptions
from .types.category import Category
from ..core.pydantic_utilities import parse_obj_as
from .errors.category_already_exists import CategoryAlreadyExists
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
import uuid
from ..core.jsonable_encoder import jsonable_encoder
from .errors.category_not_found import CategoryNotFound
from .types.delete_category_response import DeleteCategoryResponse
from .types.add_transcription_to_category_response import AddTranscriptionToCategoryResponse
from .types.remove_transcription_from_category_response import RemoveTranscriptionFromCategoryResponse
from .types.category_transcription import CategoryTranscription
from ..core.client_wrapper import AsyncClientWrapper

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


class CategoriesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._client_wrapper = client_wrapper

    def create_category(
        self,
        *,
        name: str,
        color_hex: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Category:
        """
        Create a new category

        Parameters
        ----------
        name : str
            Name of the category

        color_hex : typing.Optional[str]
            Hex color code for the category (e.g.,

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

        Returns
        -------
        Category

        Examples
        --------
        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.create_category(
            name="name",
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/categories/",
            method="POST",
            json={
                "name": name,
                "color_hex": color_hex,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Category,
                    parse_obj_as(
                        type_=Category,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 409:
                raise CategoryAlreadyExists()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def list_categories(self, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Category]:
        """
        Get all categories for the authenticated user

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

        Returns
        -------
        typing.List[Category]

        Examples
        --------
        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.list_categories()
        """
        _response = self._client_wrapper.httpx_client.request(
            "v1/categories/",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Category],
                    parse_obj_as(
                        type_=typing.List[Category],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_category(
        self, category_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> Category:
        """
        Get a specific category by ID

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

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

        Returns
        -------
        Category

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.get_category(
            category_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Category,
                    parse_obj_as(
                        type_=Category,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def update_category(
        self,
        category_id: uuid.UUID,
        *,
        name: typing.Optional[str] = OMIT,
        color_hex: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Category:
        """
        Update an existing category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category to update

        name : typing.Optional[str]
            New name for the category

        color_hex : typing.Optional[str]
            New hex color code for the category (e.g.,

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

        Returns
        -------
        Category

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.update_category(
            category_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}",
            method="PUT",
            json={
                "name": name,
                "color_hex": color_hex,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Category,
                    parse_obj_as(
                        type_=Category,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            if _response.status_code == 409:
                raise CategoryAlreadyExists()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def delete_category(
        self, category_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteCategoryResponse:
        """
        Delete a category (this will also remove all transcription associations)

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category to delete

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

        Returns
        -------
        DeleteCategoryResponse
            Returns success message

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.delete_category(
            category_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    DeleteCategoryResponse,
                    parse_obj_as(
                        type_=DeleteCategoryResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def add_transcription_to_category(
        self,
        category_id: uuid.UUID,
        *,
        transcription_id: uuid.UUID,
        position: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AddTranscriptionToCategoryResponse:
        """
        Add a transcription to a category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

        transcription_id : uuid.UUID
            ID of the transcription to add to the category

        position : typing.Optional[int]
            Optional position within the category for ordering

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

        Returns
        -------
        AddTranscriptionToCategoryResponse
            Returns success message

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.add_transcription_to_category(
            category_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
            transcription_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}/transcriptions",
            method="POST",
            json={
                "transcription_id": transcription_id,
                "position": position,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    AddTranscriptionToCategoryResponse,
                    parse_obj_as(
                        type_=AddTranscriptionToCategoryResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def remove_transcription_from_category(
        self,
        category_id: uuid.UUID,
        transcription_id: uuid.UUID,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RemoveTranscriptionFromCategoryResponse:
        """
        Remove a transcription from a category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

        transcription_id : uuid.UUID
            ID of the transcription to remove

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

        Returns
        -------
        RemoveTranscriptionFromCategoryResponse
            Returns success message

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.remove_transcription_from_category(
            category_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
            transcription_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}/transcriptions/{jsonable_encoder(transcription_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    RemoveTranscriptionFromCategoryResponse,
                    parse_obj_as(
                        type_=RemoveTranscriptionFromCategoryResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_transcription_categories(
        self, transcription_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Category]:
        """
        Get all categories for a specific transcription

        Parameters
        ----------
        transcription_id : uuid.UUID
            ID of the transcription

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

        Returns
        -------
        typing.List[Category]

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.get_transcription_categories(
            transcription_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/by-transcription/{jsonable_encoder(transcription_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Category],
                    parse_obj_as(
                        type_=typing.List[Category],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    def get_category_transcriptions(
        self, category_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[CategoryTranscription]:
        """
        Get all transcriptions in a specific category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

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

        Returns
        -------
        typing.List[CategoryTranscription]

        Examples
        --------
        import uuid

        from soferai import SoferAI

        client = SoferAI(
            api_key="YOUR_API_KEY",
        )
        client.categories.get_category_transcriptions(
            category_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}/transcriptions",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[CategoryTranscription],
                    parse_obj_as(
                        type_=typing.List[CategoryTranscription],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)


class AsyncCategoriesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._client_wrapper = client_wrapper

    async def create_category(
        self,
        *,
        name: str,
        color_hex: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Category:
        """
        Create a new category

        Parameters
        ----------
        name : str
            Name of the category

        color_hex : typing.Optional[str]
            Hex color code for the category (e.g.,

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

        Returns
        -------
        Category

        Examples
        --------
        import asyncio

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.create_category(
                name="name",
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/categories/",
            method="POST",
            json={
                "name": name,
                "color_hex": color_hex,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Category,
                    parse_obj_as(
                        type_=Category,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 409:
                raise CategoryAlreadyExists()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def list_categories(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Category]:
        """
        Get all categories for the authenticated user

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

        Returns
        -------
        typing.List[Category]

        Examples
        --------
        import asyncio

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.list_categories()


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            "v1/categories/",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Category],
                    parse_obj_as(
                        type_=typing.List[Category],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_category(
        self, category_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> Category:
        """
        Get a specific category by ID

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

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

        Returns
        -------
        Category

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.get_category(
                category_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Category,
                    parse_obj_as(
                        type_=Category,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def update_category(
        self,
        category_id: uuid.UUID,
        *,
        name: typing.Optional[str] = OMIT,
        color_hex: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> Category:
        """
        Update an existing category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category to update

        name : typing.Optional[str]
            New name for the category

        color_hex : typing.Optional[str]
            New hex color code for the category (e.g.,

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

        Returns
        -------
        Category

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.update_category(
                category_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}",
            method="PUT",
            json={
                "name": name,
                "color_hex": color_hex,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    Category,
                    parse_obj_as(
                        type_=Category,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            if _response.status_code == 409:
                raise CategoryAlreadyExists()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def delete_category(
        self, category_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteCategoryResponse:
        """
        Delete a category (this will also remove all transcription associations)

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category to delete

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

        Returns
        -------
        DeleteCategoryResponse
            Returns success message

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.delete_category(
                category_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    DeleteCategoryResponse,
                    parse_obj_as(
                        type_=DeleteCategoryResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def add_transcription_to_category(
        self,
        category_id: uuid.UUID,
        *,
        transcription_id: uuid.UUID,
        position: typing.Optional[int] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AddTranscriptionToCategoryResponse:
        """
        Add a transcription to a category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

        transcription_id : uuid.UUID
            ID of the transcription to add to the category

        position : typing.Optional[int]
            Optional position within the category for ordering

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

        Returns
        -------
        AddTranscriptionToCategoryResponse
            Returns success message

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.add_transcription_to_category(
                category_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
                transcription_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}/transcriptions",
            method="POST",
            json={
                "transcription_id": transcription_id,
                "position": position,
            },
            request_options=request_options,
            omit=OMIT,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    AddTranscriptionToCategoryResponse,
                    parse_obj_as(
                        type_=AddTranscriptionToCategoryResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def remove_transcription_from_category(
        self,
        category_id: uuid.UUID,
        transcription_id: uuid.UUID,
        *,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RemoveTranscriptionFromCategoryResponse:
        """
        Remove a transcription from a category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

        transcription_id : uuid.UUID
            ID of the transcription to remove

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

        Returns
        -------
        RemoveTranscriptionFromCategoryResponse
            Returns success message

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.remove_transcription_from_category(
                category_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
                transcription_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}/transcriptions/{jsonable_encoder(transcription_id)}",
            method="DELETE",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    RemoveTranscriptionFromCategoryResponse,
                    parse_obj_as(
                        type_=RemoveTranscriptionFromCategoryResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_transcription_categories(
        self, transcription_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[Category]:
        """
        Get all categories for a specific transcription

        Parameters
        ----------
        transcription_id : uuid.UUID
            ID of the transcription

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

        Returns
        -------
        typing.List[Category]

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.get_transcription_categories(
                transcription_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/by-transcription/{jsonable_encoder(transcription_id)}",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[Category],
                    parse_obj_as(
                        type_=typing.List[Category],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)

    async def get_category_transcriptions(
        self, category_id: uuid.UUID, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.List[CategoryTranscription]:
        """
        Get all transcriptions in a specific category

        Parameters
        ----------
        category_id : uuid.UUID
            ID of the category

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

        Returns
        -------
        typing.List[CategoryTranscription]

        Examples
        --------
        import asyncio
        import uuid

        from soferai import AsyncSoferAI

        client = AsyncSoferAI(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.categories.get_category_transcriptions(
                category_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._client_wrapper.httpx_client.request(
            f"v1/categories/{jsonable_encoder(category_id)}/transcriptions",
            method="GET",
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                return typing.cast(
                    typing.List[CategoryTranscription],
                    parse_obj_as(
                        type_=typing.List[CategoryTranscription],  # type: ignore
                        object_=_response.json(),
                    ),
                )
            if _response.status_code == 404:
                raise CategoryNotFound()
            _response_json = _response.json()
        except JSONDecodeError:
            raise ApiError(status_code=_response.status_code, body=_response.text)
        raise ApiError(status_code=_response.status_code, body=_response_json)
