# 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.task_message import TaskMessage
from ...types.task_message_content import TaskMessageContent
from .raw_client import AsyncRawBatchClient, RawBatchClient

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


class BatchClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBatchClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBatchClient
        """
        return self._raw_client

    def create(
        self,
        *,
        contents: typing.Sequence[TaskMessageContent],
        task_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[TaskMessage]:
        """
        Parameters
        ----------
        contents : typing.Sequence[TaskMessageContent]

        task_id : str

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

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

        Examples
        --------
        from terminaluse import TaskMessageContent_ClaudeMessage, TerminaluseApi

        client = TerminaluseApi(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.messages.batch.create(
            contents=[
                TaskMessageContent_ClaudeMessage(
                    author="user",
                    message_type="message_type",
                    raw_message={"key": "value"},
                )
            ],
            task_id="task_id",
        )
        """
        _response = self._raw_client.create(contents=contents, task_id=task_id, request_options=request_options)
        return _response.data

    def update(
        self,
        *,
        task_id: str,
        updates: typing.Dict[str, TaskMessageContent],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[TaskMessage]:
        """
        Parameters
        ----------
        task_id : str

        updates : typing.Dict[str, TaskMessageContent]

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

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

        Examples
        --------
        from terminaluse import TaskMessageContent_ClaudeMessage, TerminaluseApi

        client = TerminaluseApi(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )
        client.messages.batch.update(
            task_id="task_id",
            updates={
                "key": TaskMessageContent_ClaudeMessage(
                    author="user",
                    message_type="message_type",
                    raw_message={"key": "value"},
                )
            },
        )
        """
        _response = self._raw_client.update(task_id=task_id, updates=updates, request_options=request_options)
        return _response.data


class AsyncBatchClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBatchClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBatchClient
        """
        return self._raw_client

    async def create(
        self,
        *,
        contents: typing.Sequence[TaskMessageContent],
        task_id: str,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[TaskMessage]:
        """
        Parameters
        ----------
        contents : typing.Sequence[TaskMessageContent]

        task_id : str

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

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

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminaluseApi, TaskMessageContent_ClaudeMessage

        client = AsyncTerminaluseApi(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.messages.batch.create(
                contents=[
                    TaskMessageContent_ClaudeMessage(
                        author="user",
                        message_type="message_type",
                        raw_message={"key": "value"},
                    )
                ],
                task_id="task_id",
            )


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

    async def update(
        self,
        *,
        task_id: str,
        updates: typing.Dict[str, TaskMessageContent],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.List[TaskMessage]:
        """
        Parameters
        ----------
        task_id : str

        updates : typing.Dict[str, TaskMessageContent]

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

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

        Examples
        --------
        import asyncio

        from terminaluse import AsyncTerminaluseApi, TaskMessageContent_ClaudeMessage

        client = AsyncTerminaluseApi(
            agent_api_key="YOUR_AGENT_API_KEY",
            token="YOUR_TOKEN",
            base_url="https://yourhost.com/path/to/api",
        )


        async def main() -> None:
            await client.messages.batch.update(
                task_id="task_id",
                updates={
                    "key": TaskMessageContent_ClaudeMessage(
                        author="user",
                        message_type="message_type",
                        raw_message={"key": "value"},
                    )
                },
            )


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