# 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.item_id import ItemId
from ....types.order_id import OrderId
from ....types.remove_order_item_response import RemoveOrderItemResponse
from ....types.upsert_order_item_request import UpsertOrderItemRequest
from ....types.upsert_order_item_response import UpsertOrderItemResponse
from .raw_client import AsyncRawItemsClient, RawItemsClient

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


class ItemsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawItemsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawItemsClient
        """
        return self._raw_client

    def upsert(
        self,
        order_id: OrderId,
        *,
        request: UpsertOrderItemRequest,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpsertOrderItemResponse:
        """
        Adds or updates an order item on an open order. Returns the item ID and the quoted price.

        Parameters
        ----------
        order_id : OrderId
            The ID of the order.

        request : UpsertOrderItemRequest

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

        Returns
        -------
        UpsertOrderItemResponse
            Successful Response

        Examples
        --------
        from elevenlabs import (
            ElevenLabs,
            OrderItemRequestInput_Dub,
            UpsertOrderItemRequest,
        )

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.productions.orders.items.upsert(
            order_id="order_id",
            request=UpsertOrderItemRequest(
                item=OrderItemRequestInput_Dub(
                    media_id="prodmedia_01jgatk6h0fwxrtbjade61yqhx",
                    source_language="en",
                    destination_languages=["hi", "fr-FR", "de"],
                    include_captions=True,
                    include_source_captions=False,
                    instructions="Voices don't need to match the originals, prioritize native-sounding voices",
                    captions_sdh=False,
                ),
            ),
        )
        """
        _response = self._raw_client.upsert(order_id, request=request, request_options=request_options)
        return _response.data

    def remove(
        self, order_id: OrderId, item_id: ItemId, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RemoveOrderItemResponse:
        """
        Removes an order item from an open order.

        Parameters
        ----------
        order_id : OrderId
            The ID of the order.

        item_id : ItemId
            The ID of the order item.

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

        Returns
        -------
        RemoveOrderItemResponse
            Successful Response

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

        client = ElevenLabs(
            api_key="YOUR_API_KEY",
        )
        client.productions.orders.items.remove(
            order_id="order_id",
            item_id="item_id",
        )
        """
        _response = self._raw_client.remove(order_id, item_id, request_options=request_options)
        return _response.data


class AsyncItemsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawItemsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawItemsClient
        """
        return self._raw_client

    async def upsert(
        self,
        order_id: OrderId,
        *,
        request: UpsertOrderItemRequest,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpsertOrderItemResponse:
        """
        Adds or updates an order item on an open order. Returns the item ID and the quoted price.

        Parameters
        ----------
        order_id : OrderId
            The ID of the order.

        request : UpsertOrderItemRequest

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

        Returns
        -------
        UpsertOrderItemResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import (
            AsyncElevenLabs,
            OrderItemRequestInput_Dub,
            UpsertOrderItemRequest,
        )

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.productions.orders.items.upsert(
                order_id="order_id",
                request=UpsertOrderItemRequest(
                    item=OrderItemRequestInput_Dub(
                        media_id="prodmedia_01jgatk6h0fwxrtbjade61yqhx",
                        source_language="en",
                        destination_languages=["hi", "fr-FR", "de"],
                        include_captions=True,
                        include_source_captions=False,
                        instructions="Voices don't need to match the originals, prioritize native-sounding voices",
                        captions_sdh=False,
                    ),
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.upsert(order_id, request=request, request_options=request_options)
        return _response.data

    async def remove(
        self, order_id: OrderId, item_id: ItemId, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RemoveOrderItemResponse:
        """
        Removes an order item from an open order.

        Parameters
        ----------
        order_id : OrderId
            The ID of the order.

        item_id : ItemId
            The ID of the order item.

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

        Returns
        -------
        RemoveOrderItemResponse
            Successful Response

        Examples
        --------
        import asyncio

        from elevenlabs import AsyncElevenLabs

        client = AsyncElevenLabs(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.productions.orders.items.remove(
                order_id="order_id",
                item_id="item_id",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.remove(order_id, item_id, request_options=request_options)
        return _response.data
