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

import typing
from ..core.client_wrapper import SyncClientWrapper
from .raw_client import RawCheckoutClient
from .payment_links.client import PaymentLinksClient
from ..core.request_options import RequestOptions
from ..types.retrieve_location_settings_response import RetrieveLocationSettingsResponse
from ..requests.checkout_location_settings import CheckoutLocationSettingsParams
from ..types.update_location_settings_response import UpdateLocationSettingsResponse
from ..types.retrieve_merchant_settings_response import RetrieveMerchantSettingsResponse
from ..requests.checkout_merchant_settings import CheckoutMerchantSettingsParams
from ..types.update_merchant_settings_response import UpdateMerchantSettingsResponse
from ..core.client_wrapper import AsyncClientWrapper
from .raw_client import AsyncRawCheckoutClient
from .payment_links.client import AsyncPaymentLinksClient

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


class CheckoutClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawCheckoutClient(client_wrapper=client_wrapper)
        self.payment_links = PaymentLinksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawCheckoutClient
        """
        return self._raw_client

    def retrieve_location_settings(
        self, location_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RetrieveLocationSettingsResponse:
        """
        Retrieves the location-level settings for a Square-hosted checkout page.

        Parameters
        ----------
        location_id : str
            The ID of the location for which to retrieve settings.

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

        Returns
        -------
        RetrieveLocationSettingsResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.checkout.retrieve_location_settings(
            location_id="location_id",
        )
        """
        response = self._raw_client.retrieve_location_settings(location_id, request_options=request_options)
        return response.data

    def update_location_settings(
        self,
        location_id: str,
        *,
        location_settings: CheckoutLocationSettingsParams,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateLocationSettingsResponse:
        """
        Updates the location-level settings for a Square-hosted checkout page.

        Parameters
        ----------
        location_id : str
            The ID of the location for which to retrieve settings.

        location_settings : CheckoutLocationSettingsParams
            Describe your updates using the `location_settings` object. Make sure it contains only the fields that have changed.

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

        Returns
        -------
        UpdateLocationSettingsResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.checkout.update_location_settings(
            location_id="location_id",
            location_settings={},
        )
        """
        response = self._raw_client.update_location_settings(
            location_id, location_settings=location_settings, request_options=request_options
        )
        return response.data

    def retrieve_merchant_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RetrieveMerchantSettingsResponse:
        """
        Retrieves the merchant-level settings for a Square-hosted checkout page.

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

        Returns
        -------
        RetrieveMerchantSettingsResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.checkout.retrieve_merchant_settings()
        """
        response = self._raw_client.retrieve_merchant_settings(request_options=request_options)
        return response.data

    def update_merchant_settings(
        self,
        *,
        merchant_settings: CheckoutMerchantSettingsParams,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateMerchantSettingsResponse:
        """
        Updates the merchant-level settings for a Square-hosted checkout page.

        Parameters
        ----------
        merchant_settings : CheckoutMerchantSettingsParams
            Describe your updates using the `merchant_settings` object. Make sure it contains only the fields that have changed.

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

        Returns
        -------
        UpdateMerchantSettingsResponse
            Success

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

        client = Square(
            token="YOUR_TOKEN",
        )
        client.checkout.update_merchant_settings(
            merchant_settings={},
        )
        """
        response = self._raw_client.update_merchant_settings(
            merchant_settings=merchant_settings, request_options=request_options
        )
        return response.data


class AsyncCheckoutClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawCheckoutClient(client_wrapper=client_wrapper)
        self.payment_links = AsyncPaymentLinksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawCheckoutClient
        """
        return self._raw_client

    async def retrieve_location_settings(
        self, location_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RetrieveLocationSettingsResponse:
        """
        Retrieves the location-level settings for a Square-hosted checkout page.

        Parameters
        ----------
        location_id : str
            The ID of the location for which to retrieve settings.

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

        Returns
        -------
        RetrieveLocationSettingsResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.checkout.retrieve_location_settings(
                location_id="location_id",
            )


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

    async def update_location_settings(
        self,
        location_id: str,
        *,
        location_settings: CheckoutLocationSettingsParams,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateLocationSettingsResponse:
        """
        Updates the location-level settings for a Square-hosted checkout page.

        Parameters
        ----------
        location_id : str
            The ID of the location for which to retrieve settings.

        location_settings : CheckoutLocationSettingsParams
            Describe your updates using the `location_settings` object. Make sure it contains only the fields that have changed.

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

        Returns
        -------
        UpdateLocationSettingsResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.checkout.update_location_settings(
                location_id="location_id",
                location_settings={},
            )


        asyncio.run(main())
        """
        response = await self._raw_client.update_location_settings(
            location_id, location_settings=location_settings, request_options=request_options
        )
        return response.data

    async def retrieve_merchant_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> RetrieveMerchantSettingsResponse:
        """
        Retrieves the merchant-level settings for a Square-hosted checkout page.

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

        Returns
        -------
        RetrieveMerchantSettingsResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.checkout.retrieve_merchant_settings()


        asyncio.run(main())
        """
        response = await self._raw_client.retrieve_merchant_settings(request_options=request_options)
        return response.data

    async def update_merchant_settings(
        self,
        *,
        merchant_settings: CheckoutMerchantSettingsParams,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> UpdateMerchantSettingsResponse:
        """
        Updates the merchant-level settings for a Square-hosted checkout page.

        Parameters
        ----------
        merchant_settings : CheckoutMerchantSettingsParams
            Describe your updates using the `merchant_settings` object. Make sure it contains only the fields that have changed.

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

        Returns
        -------
        UpdateMerchantSettingsResponse
            Success

        Examples
        --------
        import asyncio

        from square import AsyncSquare

        client = AsyncSquare(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.checkout.update_merchant_settings(
                merchant_settings={},
            )


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