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

import typing
from ...core.client_wrapper import SyncClientWrapper
from .raw_client import RawCustomAttributesClient
from ...requests.booking_custom_attribute_delete_request import BookingCustomAttributeDeleteRequestParams
from ...core.request_options import RequestOptions
from ...types.bulk_delete_booking_custom_attributes_response import BulkDeleteBookingCustomAttributesResponse
from ...requests.booking_custom_attribute_upsert_request import BookingCustomAttributeUpsertRequestParams
from ...types.bulk_upsert_booking_custom_attributes_response import BulkUpsertBookingCustomAttributesResponse
from ...core.pagination import SyncPager
from ...types.custom_attribute import CustomAttribute
from ...core.jsonable_encoder import jsonable_encoder
from ...types.list_booking_custom_attributes_response import ListBookingCustomAttributesResponse
from ...core.unchecked_base_model import construct_type
from json.decoder import JSONDecodeError
from ...core.api_error import ApiError
from ...types.retrieve_booking_custom_attribute_response import RetrieveBookingCustomAttributeResponse
from ...requests.custom_attribute import CustomAttributeParams
from ...types.upsert_booking_custom_attribute_response import UpsertBookingCustomAttributeResponse
from ...types.delete_booking_custom_attribute_response import DeleteBookingCustomAttributeResponse
from ...core.client_wrapper import AsyncClientWrapper
from .raw_client import AsyncRawCustomAttributesClient
from ...core.pagination import AsyncPager

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


class CustomAttributesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCustomAttributesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCustomAttributesClient
        """
        return self._raw_client

    def batch_delete(
        self,
        *,
        values: typing.Dict[str, BookingCustomAttributeDeleteRequestParams],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BulkDeleteBookingCustomAttributesResponse:
        """
        Bulk deletes bookings custom attributes.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        values : typing.Dict[str, BookingCustomAttributeDeleteRequestParams]
            A map containing 1 to 25 individual Delete requests. For each request, provide an
            arbitrary ID that is unique for this `BulkDeleteBookingCustomAttributes` request and the
            information needed to delete a custom attribute.

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

        Returns
        -------
        BulkDeleteBookingCustomAttributesResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.bookings.custom_attributes.batch_delete(
            values={"key": {"booking_id": "booking_id", "key": "key"}},
        )
        """
        response = self._raw_client.batch_delete(values=values, request_options=request_options)
        return response.data

    def batch_upsert(
        self,
        *,
        values: typing.Dict[str, BookingCustomAttributeUpsertRequestParams],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BulkUpsertBookingCustomAttributesResponse:
        """
        Bulk upserts bookings custom attributes.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        values : typing.Dict[str, BookingCustomAttributeUpsertRequestParams]
            A map containing 1 to 25 individual upsert requests. For each request, provide an
            arbitrary ID that is unique for this `BulkUpsertBookingCustomAttributes` request and the
            information needed to create or update a custom attribute.

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

        Returns
        -------
        BulkUpsertBookingCustomAttributesResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.bookings.custom_attributes.batch_upsert(
            values={"key": {"booking_id": "booking_id", "custom_attribute": {}}},
        )
        """
        response = self._raw_client.batch_upsert(values=values, request_options=request_options)
        return response.data

    def list(
        self,
        booking_id: str,
        *,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        with_definitions: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SyncPager[CustomAttribute]:
        """
        Lists a booking's custom attributes.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_READ` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        limit : typing.Optional[int]
            The maximum number of results to return in a single paged response. This limit is advisory.
            The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100.
            The default value is 20. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

        cursor : typing.Optional[str]
            The cursor returned in the paged response from the previous call to this endpoint.
            Provide this cursor to retrieve the next page of results for your original request. For more
            information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

        with_definitions : typing.Optional[bool]
            Indicates whether to return the [custom attribute definition](entity:CustomAttributeDefinition) in the `definition` field of each
            custom attribute. Set this parameter to `true` to get the name and description of each custom
            attribute, information about the data type, or other definition details. The default value is `false`.

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

        Returns
        -------
        SyncPager[CustomAttribute]
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        response = client.bookings.custom_attributes.list(
            booking_id="booking_id",
        )
        for item in response:
            yield item
        # alternatively, you can paginate page-by-page
        for page in response.iter_pages():
            yield page
        """
        _response = self._raw_client._client_wrapper.httpx_client.request(
            f"v2/bookings/{jsonable_encoder(booking_id)}/custom-attributes",
            method="GET",
            params={
                "limit": limit,
                "cursor": cursor,
                "with_definitions": with_definitions,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _parsed_response = typing.cast(
                    ListBookingCustomAttributesResponse,
                    construct_type(
                        type_=ListBookingCustomAttributesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                _parsed_next = _parsed_response.cursor
                _has_next = _parsed_next is not None and _parsed_next != ""
                _get_next = lambda: self.list(
                    booking_id,
                    limit=limit,
                    cursor=_parsed_next,
                    with_definitions=with_definitions,
                    request_options=request_options,
                )
                _items = _parsed_response.custom_attributes
                return SyncPager(has_next=_has_next, items=_items, get_next=_get_next)
            _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(
        self,
        booking_id: str,
        key: str,
        *,
        with_definition: typing.Optional[bool] = None,
        version: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RetrieveBookingCustomAttributeResponse:
        """
        Retrieves a bookings custom attribute.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_READ` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        key : str
            The key of the custom attribute to retrieve. This key must match the `key` of a custom
            attribute definition in the Square seller account. If the requesting application is not the
            definition owner, you must use the qualified key.

        with_definition : typing.Optional[bool]
            Indicates whether to return the [custom attribute definition](entity:CustomAttributeDefinition) in the `definition` field of
            the custom attribute. Set this parameter to `true` to get the name and description of the custom
            attribute, information about the data type, or other definition details. The default value is `false`.

        version : typing.Optional[int]
            The current version of the custom attribute, which is used for strongly consistent reads to
            guarantee that you receive the most up-to-date data. When included in the request, Square
            returns the specified version or a higher version if one exists. If the specified version is
            higher than the current version, Square returns a `BAD_REQUEST` error.

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

        Returns
        -------
        RetrieveBookingCustomAttributeResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.bookings.custom_attributes.get(
            booking_id="booking_id",
            key="key",
        )
        """
        response = self._raw_client.get(
            booking_id, key, with_definition=with_definition, version=version, request_options=request_options
        )
        return response.data

    def upsert(
        self,
        booking_id: str,
        key: str,
        *,
        custom_attribute: CustomAttributeParams,
        idempotency_key: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpsertBookingCustomAttributeResponse:
        """
        Upserts a bookings custom attribute.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        key : str
            The key of the custom attribute to create or update. This key must match the `key` of a
            custom attribute definition in the Square seller account. If the requesting application is not
            the definition owner, you must use the qualified key.

        custom_attribute : CustomAttributeParams
            The custom attribute to create or update, with the following fields:

            - `value`. This value must conform to the `schema` specified by the definition.
            For more information, see [Value data types](https://developer.squareup.com/docs/booking-custom-attributes-api/custom-attributes#value-data-types).

            - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency)
            control for an update operation, include this optional field and specify the current version
            of the custom attribute.

        idempotency_key : typing.Optional[str]
            A unique identifier for this request, used to ensure idempotency. For more information,
            see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).

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

        Returns
        -------
        UpsertBookingCustomAttributeResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.bookings.custom_attributes.upsert(
            booking_id="booking_id",
            key="key",
            custom_attribute={},
        )
        """
        response = self._raw_client.upsert(
            booking_id,
            key,
            custom_attribute=custom_attribute,
            idempotency_key=idempotency_key,
            request_options=request_options,
        )
        return response.data

    def delete(
        self, booking_id: str, key: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteBookingCustomAttributeResponse:
        """
        Deletes a bookings custom attribute.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        key : str
            The key of the custom attribute to delete. This key must match the `key` of a custom
            attribute definition in the Square seller account. If the requesting application is not the
            definition owner, you must use the qualified key.

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

        Returns
        -------
        DeleteBookingCustomAttributeResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.bookings.custom_attributes.delete(
            booking_id="booking_id",
            key="key",
        )
        """
        response = self._raw_client.delete(booking_id, key, request_options=request_options)
        return response.data


class AsyncCustomAttributesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCustomAttributesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCustomAttributesClient
        """
        return self._raw_client

    async def batch_delete(
        self,
        *,
        values: typing.Dict[str, BookingCustomAttributeDeleteRequestParams],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BulkDeleteBookingCustomAttributesResponse:
        """
        Bulk deletes bookings custom attributes.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        values : typing.Dict[str, BookingCustomAttributeDeleteRequestParams]
            A map containing 1 to 25 individual Delete requests. For each request, provide an
            arbitrary ID that is unique for this `BulkDeleteBookingCustomAttributes` request and the
            information needed to delete a custom attribute.

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

        Returns
        -------
        BulkDeleteBookingCustomAttributesResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.bookings.custom_attributes.batch_delete(
                values={"key": {"booking_id": "booking_id", "key": "key"}},
            )


        asyncio.run(main())
        """
        response = await self._raw_client.batch_delete(values=values, request_options=request_options)
        return response.data

    async def batch_upsert(
        self,
        *,
        values: typing.Dict[str, BookingCustomAttributeUpsertRequestParams],
        request_options: typing.Optional[RequestOptions] = None,
    ) -> BulkUpsertBookingCustomAttributesResponse:
        """
        Bulk upserts bookings custom attributes.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        values : typing.Dict[str, BookingCustomAttributeUpsertRequestParams]
            A map containing 1 to 25 individual upsert requests. For each request, provide an
            arbitrary ID that is unique for this `BulkUpsertBookingCustomAttributes` request and the
            information needed to create or update a custom attribute.

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

        Returns
        -------
        BulkUpsertBookingCustomAttributesResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.bookings.custom_attributes.batch_upsert(
                values={"key": {"booking_id": "booking_id", "custom_attribute": {}}},
            )


        asyncio.run(main())
        """
        response = await self._raw_client.batch_upsert(values=values, request_options=request_options)
        return response.data

    async def list(
        self,
        booking_id: str,
        *,
        limit: typing.Optional[int] = None,
        cursor: typing.Optional[str] = None,
        with_definitions: typing.Optional[bool] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> AsyncPager[CustomAttribute]:
        """
        Lists a booking's custom attributes.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_READ` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        limit : typing.Optional[int]
            The maximum number of results to return in a single paged response. This limit is advisory.
            The response might contain more or fewer results. The minimum value is 1 and the maximum value is 100.
            The default value is 20. For more information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

        cursor : typing.Optional[str]
            The cursor returned in the paged response from the previous call to this endpoint.
            Provide this cursor to retrieve the next page of results for your original request. For more
            information, see [Pagination](https://developer.squareup.com/docs/build-basics/common-api-patterns/pagination).

        with_definitions : typing.Optional[bool]
            Indicates whether to return the [custom attribute definition](entity:CustomAttributeDefinition) in the `definition` field of each
            custom attribute. Set this parameter to `true` to get the name and description of each custom
            attribute, information about the data type, or other definition details. The default value is `false`.

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

        Returns
        -------
        AsyncPager[CustomAttribute]
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            response = await client.bookings.custom_attributes.list(
                booking_id="booking_id",
            )
            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())
        """
        _response = await self._raw_client._client_wrapper.httpx_client.request(
            f"v2/bookings/{jsonable_encoder(booking_id)}/custom-attributes",
            method="GET",
            params={
                "limit": limit,
                "cursor": cursor,
                "with_definitions": with_definitions,
            },
            request_options=request_options,
        )
        try:
            if 200 <= _response.status_code < 300:
                _parsed_response = typing.cast(
                    ListBookingCustomAttributesResponse,
                    construct_type(
                        type_=ListBookingCustomAttributesResponse,  # type: ignore
                        object_=_response.json(),
                    ),
                )
                _parsed_next = _parsed_response.cursor
                _has_next = _parsed_next is not None and _parsed_next != ""
                _get_next = lambda: self.list(
                    booking_id,
                    limit=limit,
                    cursor=_parsed_next,
                    with_definitions=with_definitions,
                    request_options=request_options,
                )
                _items = _parsed_response.custom_attributes
                return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next)
            _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(
        self,
        booking_id: str,
        key: str,
        *,
        with_definition: typing.Optional[bool] = None,
        version: typing.Optional[int] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> RetrieveBookingCustomAttributeResponse:
        """
        Retrieves a bookings custom attribute.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_READ` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        key : str
            The key of the custom attribute to retrieve. This key must match the `key` of a custom
            attribute definition in the Square seller account. If the requesting application is not the
            definition owner, you must use the qualified key.

        with_definition : typing.Optional[bool]
            Indicates whether to return the [custom attribute definition](entity:CustomAttributeDefinition) in the `definition` field of
            the custom attribute. Set this parameter to `true` to get the name and description of the custom
            attribute, information about the data type, or other definition details. The default value is `false`.

        version : typing.Optional[int]
            The current version of the custom attribute, which is used for strongly consistent reads to
            guarantee that you receive the most up-to-date data. When included in the request, Square
            returns the specified version or a higher version if one exists. If the specified version is
            higher than the current version, Square returns a `BAD_REQUEST` error.

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

        Returns
        -------
        RetrieveBookingCustomAttributeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.bookings.custom_attributes.get(
                booking_id="booking_id",
                key="key",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.get(
            booking_id, key, with_definition=with_definition, version=version, request_options=request_options
        )
        return response.data

    async def upsert(
        self,
        booking_id: str,
        key: str,
        *,
        custom_attribute: CustomAttributeParams,
        idempotency_key: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpsertBookingCustomAttributeResponse:
        """
        Upserts a bookings custom attribute.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        key : str
            The key of the custom attribute to create or update. This key must match the `key` of a
            custom attribute definition in the Square seller account. If the requesting application is not
            the definition owner, you must use the qualified key.

        custom_attribute : CustomAttributeParams
            The custom attribute to create or update, with the following fields:

            - `value`. This value must conform to the `schema` specified by the definition.
            For more information, see [Value data types](https://developer.squareup.com/docs/booking-custom-attributes-api/custom-attributes#value-data-types).

            - `version`. To enable [optimistic concurrency](https://developer.squareup.com/docs/build-basics/common-api-patterns/optimistic-concurrency)
            control for an update operation, include this optional field and specify the current version
            of the custom attribute.

        idempotency_key : typing.Optional[str]
            A unique identifier for this request, used to ensure idempotency. For more information,
            see [Idempotency](https://developer.squareup.com/docs/build-basics/common-api-patterns/idempotency).

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

        Returns
        -------
        UpsertBookingCustomAttributeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.bookings.custom_attributes.upsert(
                booking_id="booking_id",
                key="key",
                custom_attribute={},
            )


        asyncio.run(main())
        """
        response = await self._raw_client.upsert(
            booking_id,
            key,
            custom_attribute=custom_attribute,
            idempotency_key=idempotency_key,
            request_options=request_options,
        )
        return response.data

    async def delete(
        self, booking_id: str, key: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> DeleteBookingCustomAttributeResponse:
        """
        Deletes a bookings custom attribute.

        To call this endpoint with buyer-level permissions, set `APPOINTMENTS_WRITE` for the OAuth scope.
        To call this endpoint with seller-level permissions, set `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.

        For calls to this endpoint with seller-level permissions to succeed, the seller must have subscribed to *Appointments Plus*
        or *Appointments Premium*.

        Parameters
        ----------
        booking_id : str
            The ID of the target [booking](entity:Booking).

        key : str
            The key of the custom attribute to delete. This key must match the `key` of a custom
            attribute definition in the Square seller account. If the requesting application is not the
            definition owner, you must use the qualified key.

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

        Returns
        -------
        DeleteBookingCustomAttributeResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.bookings.custom_attributes.delete(
                booking_id="booking_id",
                key="key",
            )


        asyncio.run(main())
        """
        response = await self._raw_client.delete(booking_id, key, request_options=request_options)
        return response.data
