# 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 ...requests.break_type import BreakTypeParams
from ...types.break_type import BreakType
from ...types.create_break_type_response import CreateBreakTypeResponse
from ...types.delete_break_type_response import DeleteBreakTypeResponse
from ...types.get_break_type_response import GetBreakTypeResponse
from ...types.update_break_type_response import UpdateBreakTypeResponse
from .raw_client import AsyncRawBreakTypesClient, RawBreakTypesClient

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


class BreakTypesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBreakTypesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawBreakTypesClient
        """
        return self._raw_client

    def list(
        self,
        *,
        location_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[BreakType]:
        """
        Returns a paginated list of `BreakType` instances for a business.

        Parameters
        ----------
        location_id : typing.Optional[str]
            Filter the returned `BreakType` results to only those that are associated with the
            specified location.

        limit : typing.Optional[int]
            The maximum number of `BreakType` results to return per page. The number can range between 1
            and 200. The default is 200.

        cursor : typing.Optional[str]
            A pointer to the next page of `BreakType` results to fetch.

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

        Returns
        -------
        SyncPager[BreakType]
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        response = client.labor.break_types.list()
        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.list(
            location_id=location_id, limit=limit, cursor=cursor, request_options=request_options
        )

    def create(
        self,
        *,
        break_type: BreakTypeParams,
        idempotency_key: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateBreakTypeResponse:
        """
        Creates a new `BreakType`.

        A `BreakType` is a template for creating `Break` objects.
        You must provide the following values in your request to this
        endpoint:

        - `location_id`
        - `break_name`
        - `expected_duration`
        - `is_paid`

        You can only have three `BreakType` instances per location. If you attempt to add a fourth
        `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of 3 breaks per location."
        is returned.

        Parameters
        ----------
        break_type : BreakTypeParams
            The `BreakType` to be created.

        idempotency_key : typing.Optional[str]
            A unique string value to ensure the idempotency of the operation.

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

        Returns
        -------
        CreateBreakTypeResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.labor.break_types.create(
            idempotency_key="PAD3NG5KSN2GL",
            break_type={
                "location_id": "CGJN03P1D08GF",
                "break_name": "Lunch Break",
                "expected_duration": "PT30M",
                "is_paid": True,
            },
        )
        """
        _response = self._raw_client.create(
            break_type=break_type, idempotency_key=idempotency_key, request_options=request_options
        )
        return _response.data

    def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetBreakTypeResponse:
        """
        Returns a single `BreakType` specified by `id`.

        Parameters
        ----------
        id : str
            The UUID for the `BreakType` being retrieved.

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

        Returns
        -------
        GetBreakTypeResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.labor.break_types.get(
            id="id",
        )
        """
        _response = self._raw_client.get(id, request_options=request_options)
        return _response.data

    def update(
        self, id: str, *, break_type: BreakTypeParams, request_options: typing.Optional[RequestOptions] = None
    ) -> UpdateBreakTypeResponse:
        """
        Updates an existing `BreakType`.

        Parameters
        ----------
        id : str
             The UUID for the `BreakType` being updated.

        break_type : BreakTypeParams
            The updated `BreakType`.

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

        Returns
        -------
        UpdateBreakTypeResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.labor.break_types.update(
            id="id",
            break_type={
                "location_id": "26M7H24AZ9N6R",
                "break_name": "Lunch",
                "expected_duration": "PT50M",
                "is_paid": True,
                "version": 1,
            },
        )
        """
        _response = self._raw_client.update(id, break_type=break_type, request_options=request_options)
        return _response.data

    def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DeleteBreakTypeResponse:
        """
        Deletes an existing `BreakType`.

        A `BreakType` can be deleted even if it is referenced from a `Shift`.

        Parameters
        ----------
        id : str
            The UUID for the `BreakType` being deleted.

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

        Returns
        -------
        DeleteBreakTypeResponse
            Success

        Examples
        --------
        from square import Square

        client = Square(
            token="YOUR_TOKEN",
        )
        client.labor.break_types.delete(
            id="id",
        )
        """
        _response = self._raw_client.delete(id, request_options=request_options)
        return _response.data


class AsyncBreakTypesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBreakTypesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawBreakTypesClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        location_id: typing.Optional[str] = None,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[BreakType]:
        """
        Returns a paginated list of `BreakType` instances for a business.

        Parameters
        ----------
        location_id : typing.Optional[str]
            Filter the returned `BreakType` results to only those that are associated with the
            specified location.

        limit : typing.Optional[int]
            The maximum number of `BreakType` results to return per page. The number can range between 1
            and 200. The default is 200.

        cursor : typing.Optional[str]
            A pointer to the next page of `BreakType` results to fetch.

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

        Returns
        -------
        AsyncPager[BreakType]
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            response = await client.labor.break_types.list()
            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.list(
            location_id=location_id, limit=limit, cursor=cursor, request_options=request_options
        )

    async def create(
        self,
        *,
        break_type: BreakTypeParams,
        idempotency_key: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> CreateBreakTypeResponse:
        """
        Creates a new `BreakType`.

        A `BreakType` is a template for creating `Break` objects.
        You must provide the following values in your request to this
        endpoint:

        - `location_id`
        - `break_name`
        - `expected_duration`
        - `is_paid`

        You can only have three `BreakType` instances per location. If you attempt to add a fourth
        `BreakType` for a location, an `INVALID_REQUEST_ERROR` "Exceeded limit of 3 breaks per location."
        is returned.

        Parameters
        ----------
        break_type : BreakTypeParams
            The `BreakType` to be created.

        idempotency_key : typing.Optional[str]
            A unique string value to ensure the idempotency of the operation.

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

        Returns
        -------
        CreateBreakTypeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.labor.break_types.create(
                idempotency_key="PAD3NG5KSN2GL",
                break_type={
                    "location_id": "CGJN03P1D08GF",
                    "break_name": "Lunch Break",
                    "expected_duration": "PT30M",
                    "is_paid": True,
                },
            )


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

    async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> GetBreakTypeResponse:
        """
        Returns a single `BreakType` specified by `id`.

        Parameters
        ----------
        id : str
            The UUID for the `BreakType` being retrieved.

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

        Returns
        -------
        GetBreakTypeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.labor.break_types.get(
                id="id",
            )


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

    async def update(
        self, id: str, *, break_type: BreakTypeParams, request_options: typing.Optional[RequestOptions] = None
    ) -> UpdateBreakTypeResponse:
        """
        Updates an existing `BreakType`.

        Parameters
        ----------
        id : str
             The UUID for the `BreakType` being updated.

        break_type : BreakTypeParams
            The updated `BreakType`.

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

        Returns
        -------
        UpdateBreakTypeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.labor.break_types.update(
                id="id",
                break_type={
                    "location_id": "26M7H24AZ9N6R",
                    "break_name": "Lunch",
                    "expected_duration": "PT50M",
                    "is_paid": True,
                    "version": 1,
                },
            )


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

    async def delete(
        self, id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteBreakTypeResponse:
        """
        Deletes an existing `BreakType`.

        A `BreakType` can be deleted even if it is referenced from a `Shift`.

        Parameters
        ----------
        id : str
            The UUID for the `BreakType` being deleted.

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

        Returns
        -------
        DeleteBreakTypeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.labor.break_types.delete(
                id="id",
            )


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