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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.pagination import AsyncPager, SyncPager
from ..core.request_options import RequestOptions
from ..types.comment_response import CommentResponse
from ..types.comment_with_includes import CommentWithIncludes
from ..types.comment_with_includes_response import CommentWithIncludesResponse
from ..types.comments_with_includes_response import CommentsWithIncludesResponse
from ..types.include_total_count import IncludeTotalCount
from ..types.request_after_opaque_cursor import RequestAfterOpaqueCursor
from ..types.request_page_size import RequestPageSize
from ..types.uuid_ import Uuid
from .raw_client import AsyncRawCommentsClient, RawCommentsClient
from .types.comments_index_request_include import CommentsIndexRequestInclude
from .types.comments_show_request_include import CommentsShowRequestInclude
from .types.create_comment_params_data import CreateCommentParamsData
from .types.update_comment_params_data import UpdateCommentParamsData

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


class CommentsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCommentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCommentsClient
        """
        return self._raw_client

    def show(
        self,
        account_id: Uuid,
        comment_id: Uuid,
        *,
        timestamp_as_timecode: typing.Optional[bool] = None,
        include: typing.Optional[CommentsShowRequestInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CommentWithIncludesResponse:
        """
        Show a single comment on a file. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        comment_id : Uuid


        timestamp_as_timecode : typing.Optional[bool]


        include : typing.Optional[CommentsShowRequestInclude]


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

        Returns
        -------
        CommentWithIncludesResponse
            OK

        Examples
        --------
        from frameio import Frameio

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.comments.show(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            comment_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            timestamp_as_timecode=True,
            include="owner",
        )
        """
        _response = self._raw_client.show(
            account_id,
            comment_id,
            timestamp_as_timecode=timestamp_as_timecode,
            include=include,
            request_options=request_options,
        )
        return _response.data

    def delete(
        self, account_id: Uuid, comment_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete comment from an asset. <br>Rate Limits: 60 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        comment_id : Uuid


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

        Returns
        -------
        None

        Examples
        --------
        from frameio import Frameio

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.comments.delete(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            comment_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
        )
        """
        _response = self._raw_client.delete(account_id, comment_id, request_options=request_options)
        return _response.data

    def update(
        self,
        account_id: Uuid,
        comment_id: Uuid,
        *,
        data: UpdateCommentParamsData,
        timestamp_as_timecode: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CommentResponse:
        """
        Update comment on given asset. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        comment_id : Uuid


        data : UpdateCommentParamsData

        timestamp_as_timecode : typing.Optional[bool]


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

        Returns
        -------
        CommentResponse
            OK

        Examples
        --------
        from frameio import Frameio
        from frameio.comments import UpdateCommentParamsData

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.comments.update(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            comment_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            timestamp_as_timecode=True,
            data=UpdateCommentParamsData(
                annotation='[{"tool":"rect","color":"#F22237","size":8,"x":0.277726001863933,"y":0.12909555568499534,"w":0.3153168321877913,"h":0.5308131407269339,"ix":0.277726001863933,"iy":0.12909555568499534,"radius":8}]',
                completed=False,
                page=4,
                text="This is great!",
            ),
        )
        """
        _response = self._raw_client.update(
            account_id,
            comment_id,
            data=data,
            timestamp_as_timecode=timestamp_as_timecode,
            request_options=request_options,
        )
        return _response.data

    def index(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        timestamp_as_timecode: typing.Optional[bool] = None,
        include: typing.Optional[CommentsIndexRequestInclude] = None,
        after: typing.Optional[RequestAfterOpaqueCursor] = None,
        page_size: typing.Optional[RequestPageSize] = None,
        include_total_count: typing.Optional[IncludeTotalCount] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[CommentWithIncludes, CommentsWithIncludesResponse]:
        """
        List comments on a given asset. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        file_id : Uuid


        timestamp_as_timecode : typing.Optional[bool]


        include : typing.Optional[CommentsIndexRequestInclude]


        after : typing.Optional[RequestAfterOpaqueCursor]
            Opaque Cursor query param for requests returning paginated results.
            <br/>
            NOTE: this value is auto-generated and included as part of links from a previous response. It is not intended to be human readable.

        page_size : typing.Optional[RequestPageSize]


        include_total_count : typing.Optional[IncludeTotalCount]


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

        Returns
        -------
        SyncPager[CommentWithIncludes, CommentsWithIncludesResponse]
            OK

        Examples
        --------
        from frameio import Frameio

        client = Frameio(
            token="YOUR_TOKEN",
        )
        response = client.comments.index(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            file_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            timestamp_as_timecode=True,
            include="owner",
            after="<opaque_cursor>",
            page_size=10,
            include_total_count=False,
        )
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        return self._raw_client.index(
            account_id,
            file_id,
            timestamp_as_timecode=timestamp_as_timecode,
            include=include,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )

    def create(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        data: CreateCommentParamsData,
        timestamp_as_timecode: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CommentResponse:
        """
        Create a comment on a file. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        file_id : Uuid


        data : CreateCommentParamsData

        timestamp_as_timecode : typing.Optional[bool]


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

        Returns
        -------
        CommentResponse
            Created

        Examples
        --------
        from frameio import Frameio
        from frameio.comments import CreateCommentParamsData

        client = Frameio(
            token="YOUR_TOKEN",
        )
        client.comments.create(
            account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            file_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            timestamp_as_timecode=True,
            data=CreateCommentParamsData(
                annotation='[{"tool":"rect","color":"#F22237","size":8,"x":0.277726001863933,"y":0.12909555568499534,"w":0.3153168321877913,"h":0.5308131407269339,"ix":0.277726001863933,"iy":0.12909555568499534,"radius":8}]',
                completed=False,
                page=4,
                text="This is great!",
                timestamp="00:00:02:12",
            ),
        )
        """
        _response = self._raw_client.create(
            account_id, file_id, data=data, timestamp_as_timecode=timestamp_as_timecode, request_options=request_options
        )
        return _response.data


class AsyncCommentsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCommentsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCommentsClient
        """
        return self._raw_client

    async def show(
        self,
        account_id: Uuid,
        comment_id: Uuid,
        *,
        timestamp_as_timecode: typing.Optional[bool] = None,
        include: typing.Optional[CommentsShowRequestInclude] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CommentWithIncludesResponse:
        """
        Show a single comment on a file. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        comment_id : Uuid


        timestamp_as_timecode : typing.Optional[bool]


        include : typing.Optional[CommentsShowRequestInclude]


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

        Returns
        -------
        CommentWithIncludesResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.comments.show(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                comment_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                timestamp_as_timecode=True,
                include="owner",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.show(
            account_id,
            comment_id,
            timestamp_as_timecode=timestamp_as_timecode,
            include=include,
            request_options=request_options,
        )
        return _response.data

    async def delete(
        self, account_id: Uuid, comment_id: Uuid, *, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Delete comment from an asset. <br>Rate Limits: 60 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        comment_id : Uuid


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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.comments.delete(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                comment_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.delete(account_id, comment_id, request_options=request_options)
        return _response.data

    async def update(
        self,
        account_id: Uuid,
        comment_id: Uuid,
        *,
        data: UpdateCommentParamsData,
        timestamp_as_timecode: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CommentResponse:
        """
        Update comment on given asset. <br>Rate Limits: 10 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        comment_id : Uuid


        data : UpdateCommentParamsData

        timestamp_as_timecode : typing.Optional[bool]


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

        Returns
        -------
        CommentResponse
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio
        from frameio.comments import UpdateCommentParamsData

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.comments.update(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                comment_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                timestamp_as_timecode=True,
                data=UpdateCommentParamsData(
                    annotation='[{"tool":"rect","color":"#F22237","size":8,"x":0.277726001863933,"y":0.12909555568499534,"w":0.3153168321877913,"h":0.5308131407269339,"ix":0.277726001863933,"iy":0.12909555568499534,"radius":8}]',
                    completed=False,
                    page=4,
                    text="This is great!",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update(
            account_id,
            comment_id,
            data=data,
            timestamp_as_timecode=timestamp_as_timecode,
            request_options=request_options,
        )
        return _response.data

    async def index(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        timestamp_as_timecode: typing.Optional[bool] = None,
        include: typing.Optional[CommentsIndexRequestInclude] = None,
        after: typing.Optional[RequestAfterOpaqueCursor] = None,
        page_size: typing.Optional[RequestPageSize] = None,
        include_total_count: typing.Optional[IncludeTotalCount] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[CommentWithIncludes, CommentsWithIncludesResponse]:
        """
        List comments on a given asset. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        file_id : Uuid


        timestamp_as_timecode : typing.Optional[bool]


        include : typing.Optional[CommentsIndexRequestInclude]


        after : typing.Optional[RequestAfterOpaqueCursor]
            Opaque Cursor query param for requests returning paginated results.
            <br/>
            NOTE: this value is auto-generated and included as part of links from a previous response. It is not intended to be human readable.

        page_size : typing.Optional[RequestPageSize]


        include_total_count : typing.Optional[IncludeTotalCount]


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

        Returns
        -------
        AsyncPager[CommentWithIncludes, CommentsWithIncludesResponse]
            OK

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            response = await client.comments.index(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                file_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                timestamp_as_timecode=True,
                include="owner",
                after="<opaque_cursor>",
                page_size=10,
                include_total_count=False,
            )
            async for item in response:
                yield item

            # alternatively, you can paginate page-by-page
            async for page in response.iter_pages():
                yield page


        asyncio.run(main())
        """
        return await self._raw_client.index(
            account_id,
            file_id,
            timestamp_as_timecode=timestamp_as_timecode,
            include=include,
            after=after,
            page_size=page_size,
            include_total_count=include_total_count,
            request_options=request_options,
        )

    async def create(
        self,
        account_id: Uuid,
        file_id: Uuid,
        *,
        data: CreateCommentParamsData,
        timestamp_as_timecode: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CommentResponse:
        """
        Create a comment on a file. <br>Rate Limits: 100 calls per 1.00 minute(s) per account_user

        Parameters
        ----------
        account_id : Uuid


        file_id : Uuid


        data : CreateCommentParamsData

        timestamp_as_timecode : typing.Optional[bool]


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

        Returns
        -------
        CommentResponse
            Created

        Examples
        --------
        import asyncio

        from frameio import AsyncFrameio
        from frameio.comments import CreateCommentParamsData

        client = AsyncFrameio(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.comments.create(
                account_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                file_id="b2702c44-c6da-4bb6-8bbd-be6e547ccf1b",
                timestamp_as_timecode=True,
                data=CreateCommentParamsData(
                    annotation='[{"tool":"rect","color":"#F22237","size":8,"x":0.277726001863933,"y":0.12909555568499534,"w":0.3153168321877913,"h":0.5308131407269339,"ix":0.277726001863933,"iy":0.12909555568499534,"radius":8}]',
                    completed=False,
                    page=4,
                    text="This is great!",
                    timestamp="00:00:02:12",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.create(
            account_id, file_id, data=data, timestamp_as_timecode=timestamp_as_timecode, request_options=request_options
        )
        return _response.data
