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

from __future__ import annotations

import os
import typing

import httpx
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .environment import SquareEnvironment

if typing.TYPE_CHECKING:
    from .apple_pay.client import ApplePayClient, AsyncApplePayClient
    from .bank_accounts.client import AsyncBankAccountsClient, BankAccountsClient
    from .bookings.client import AsyncBookingsClient, BookingsClient
    from .cards.client import AsyncCardsClient, CardsClient
    from .cash_drawers.client import AsyncCashDrawersClient, CashDrawersClient
    from .catalog.client import AsyncCatalogClient, CatalogClient
    from .channels.client import AsyncChannelsClient, ChannelsClient
    from .checkout.client import AsyncCheckoutClient, CheckoutClient
    from .customers.client import AsyncCustomersClient, CustomersClient
    from .devices.client import AsyncDevicesClient, DevicesClient
    from .disputes.client import AsyncDisputesClient, DisputesClient
    from .employees.client import AsyncEmployeesClient, EmployeesClient
    from .events.client import AsyncEventsClient, EventsClient
    from .gift_cards.client import AsyncGiftCardsClient, GiftCardsClient
    from .inventory.client import AsyncInventoryClient, InventoryClient
    from .invoices.client import AsyncInvoicesClient, InvoicesClient
    from .labor.client import AsyncLaborClient, LaborClient
    from .locations.client import AsyncLocationsClient, LocationsClient
    from .loyalty.client import AsyncLoyaltyClient, LoyaltyClient
    from .merchants.client import AsyncMerchantsClient, MerchantsClient
    from .o_auth.client import AsyncOAuthClient, OAuthClient
    from .orders.client import AsyncOrdersClient, OrdersClient
    from .payments.client import AsyncPaymentsClient, PaymentsClient
    from .payouts.client import AsyncPayoutsClient, PayoutsClient
    from .refunds.client import AsyncRefundsClient, RefundsClient
    from .sites.client import AsyncSitesClient, SitesClient
    from .snippets.client import AsyncSnippetsClient, SnippetsClient
    from .subscriptions.client import AsyncSubscriptionsClient, SubscriptionsClient
    from .team.client import AsyncTeamClient, TeamClient
    from .team_members.client import AsyncTeamMembersClient, TeamMembersClient
    from .terminal.client import AsyncTerminalClient, TerminalClient
    from .transfer_orders.client import AsyncTransferOrdersClient, TransferOrdersClient
    from .v1transactions.client import AsyncV1TransactionsClient, V1TransactionsClient
    from .vendors.client import AsyncVendorsClient, VendorsClient
    from .webhooks.client import AsyncWebhooksClient, WebhooksClient


class Square:
    """
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : SquareEnvironment
        The environment to use for requests from the client. from .environment import SquareEnvironment



        Defaults to SquareEnvironment.PRODUCTION



    token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.Client]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    version : typing.Optional[str]
    Examples
    --------
    from square import Square

    client = Square(
        token="YOUR_TOKEN",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: SquareEnvironment = SquareEnvironment.PRODUCTION,
        token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("SQUARE_TOKEN"),
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.Client] = None,
        version: typing.Optional[str] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
        )
        self._client_wrapper = SyncClientWrapper(
            base_url=_get_base_url(base_url=base_url, environment=environment),
            token=token,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.Client(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
            version=version,
        )
        self._o_auth: typing.Optional[OAuthClient] = None
        self._v1transactions: typing.Optional[V1TransactionsClient] = None
        self._apple_pay: typing.Optional[ApplePayClient] = None
        self._bank_accounts: typing.Optional[BankAccountsClient] = None
        self._bookings: typing.Optional[BookingsClient] = None
        self._cards: typing.Optional[CardsClient] = None
        self._catalog: typing.Optional[CatalogClient] = None
        self._channels: typing.Optional[ChannelsClient] = None
        self._customers: typing.Optional[CustomersClient] = None
        self._devices: typing.Optional[DevicesClient] = None
        self._disputes: typing.Optional[DisputesClient] = None
        self._employees: typing.Optional[EmployeesClient] = None
        self._events: typing.Optional[EventsClient] = None
        self._gift_cards: typing.Optional[GiftCardsClient] = None
        self._inventory: typing.Optional[InventoryClient] = None
        self._invoices: typing.Optional[InvoicesClient] = None
        self._labor: typing.Optional[LaborClient] = None
        self._locations: typing.Optional[LocationsClient] = None
        self._loyalty: typing.Optional[LoyaltyClient] = None
        self._merchants: typing.Optional[MerchantsClient] = None
        self._checkout: typing.Optional[CheckoutClient] = None
        self._orders: typing.Optional[OrdersClient] = None
        self._payments: typing.Optional[PaymentsClient] = None
        self._payouts: typing.Optional[PayoutsClient] = None
        self._refunds: typing.Optional[RefundsClient] = None
        self._sites: typing.Optional[SitesClient] = None
        self._snippets: typing.Optional[SnippetsClient] = None
        self._subscriptions: typing.Optional[SubscriptionsClient] = None
        self._team_members: typing.Optional[TeamMembersClient] = None
        self._team: typing.Optional[TeamClient] = None
        self._terminal: typing.Optional[TerminalClient] = None
        self._transfer_orders: typing.Optional[TransferOrdersClient] = None
        self._vendors: typing.Optional[VendorsClient] = None
        self._cash_drawers: typing.Optional[CashDrawersClient] = None
        self._webhooks: typing.Optional[WebhooksClient] = None

    @property
    def o_auth(self):
        if self._o_auth is None:
            from .o_auth.client import OAuthClient  # noqa: E402

            self._o_auth = OAuthClient(client_wrapper=self._client_wrapper)
        return self._o_auth

    @property
    def v1transactions(self):
        if self._v1transactions is None:
            from .v1transactions.client import V1TransactionsClient  # noqa: E402

            self._v1transactions = V1TransactionsClient(client_wrapper=self._client_wrapper)
        return self._v1transactions

    @property
    def apple_pay(self):
        if self._apple_pay is None:
            from .apple_pay.client import ApplePayClient  # noqa: E402

            self._apple_pay = ApplePayClient(client_wrapper=self._client_wrapper)
        return self._apple_pay

    @property
    def bank_accounts(self):
        if self._bank_accounts is None:
            from .bank_accounts.client import BankAccountsClient  # noqa: E402

            self._bank_accounts = BankAccountsClient(client_wrapper=self._client_wrapper)
        return self._bank_accounts

    @property
    def bookings(self):
        if self._bookings is None:
            from .bookings.client import BookingsClient  # noqa: E402

            self._bookings = BookingsClient(client_wrapper=self._client_wrapper)
        return self._bookings

    @property
    def cards(self):
        if self._cards is None:
            from .cards.client import CardsClient  # noqa: E402

            self._cards = CardsClient(client_wrapper=self._client_wrapper)
        return self._cards

    @property
    def catalog(self):
        if self._catalog is None:
            from .catalog.client import CatalogClient  # noqa: E402

            self._catalog = CatalogClient(client_wrapper=self._client_wrapper)
        return self._catalog

    @property
    def channels(self):
        if self._channels is None:
            from .channels.client import ChannelsClient  # noqa: E402

            self._channels = ChannelsClient(client_wrapper=self._client_wrapper)
        return self._channels

    @property
    def customers(self):
        if self._customers is None:
            from .customers.client import CustomersClient  # noqa: E402

            self._customers = CustomersClient(client_wrapper=self._client_wrapper)
        return self._customers

    @property
    def devices(self):
        if self._devices is None:
            from .devices.client import DevicesClient  # noqa: E402

            self._devices = DevicesClient(client_wrapper=self._client_wrapper)
        return self._devices

    @property
    def disputes(self):
        if self._disputes is None:
            from .disputes.client import DisputesClient  # noqa: E402

            self._disputes = DisputesClient(client_wrapper=self._client_wrapper)
        return self._disputes

    @property
    def employees(self):
        if self._employees is None:
            from .employees.client import EmployeesClient  # noqa: E402

            self._employees = EmployeesClient(client_wrapper=self._client_wrapper)
        return self._employees

    @property
    def events(self):
        if self._events is None:
            from .events.client import EventsClient  # noqa: E402

            self._events = EventsClient(client_wrapper=self._client_wrapper)
        return self._events

    @property
    def gift_cards(self):
        if self._gift_cards is None:
            from .gift_cards.client import GiftCardsClient  # noqa: E402

            self._gift_cards = GiftCardsClient(client_wrapper=self._client_wrapper)
        return self._gift_cards

    @property
    def inventory(self):
        if self._inventory is None:
            from .inventory.client import InventoryClient  # noqa: E402

            self._inventory = InventoryClient(client_wrapper=self._client_wrapper)
        return self._inventory

    @property
    def invoices(self):
        if self._invoices is None:
            from .invoices.client import InvoicesClient  # noqa: E402

            self._invoices = InvoicesClient(client_wrapper=self._client_wrapper)
        return self._invoices

    @property
    def labor(self):
        if self._labor is None:
            from .labor.client import LaborClient  # noqa: E402

            self._labor = LaborClient(client_wrapper=self._client_wrapper)
        return self._labor

    @property
    def locations(self):
        if self._locations is None:
            from .locations.client import LocationsClient  # noqa: E402

            self._locations = LocationsClient(client_wrapper=self._client_wrapper)
        return self._locations

    @property
    def loyalty(self):
        if self._loyalty is None:
            from .loyalty.client import LoyaltyClient  # noqa: E402

            self._loyalty = LoyaltyClient(client_wrapper=self._client_wrapper)
        return self._loyalty

    @property
    def merchants(self):
        if self._merchants is None:
            from .merchants.client import MerchantsClient  # noqa: E402

            self._merchants = MerchantsClient(client_wrapper=self._client_wrapper)
        return self._merchants

    @property
    def checkout(self):
        if self._checkout is None:
            from .checkout.client import CheckoutClient  # noqa: E402

            self._checkout = CheckoutClient(client_wrapper=self._client_wrapper)
        return self._checkout

    @property
    def orders(self):
        if self._orders is None:
            from .orders.client import OrdersClient  # noqa: E402

            self._orders = OrdersClient(client_wrapper=self._client_wrapper)
        return self._orders

    @property
    def payments(self):
        if self._payments is None:
            from .payments.client import PaymentsClient  # noqa: E402

            self._payments = PaymentsClient(client_wrapper=self._client_wrapper)
        return self._payments

    @property
    def payouts(self):
        if self._payouts is None:
            from .payouts.client import PayoutsClient  # noqa: E402

            self._payouts = PayoutsClient(client_wrapper=self._client_wrapper)
        return self._payouts

    @property
    def refunds(self):
        if self._refunds is None:
            from .refunds.client import RefundsClient  # noqa: E402

            self._refunds = RefundsClient(client_wrapper=self._client_wrapper)
        return self._refunds

    @property
    def sites(self):
        if self._sites is None:
            from .sites.client import SitesClient  # noqa: E402

            self._sites = SitesClient(client_wrapper=self._client_wrapper)
        return self._sites

    @property
    def snippets(self):
        if self._snippets is None:
            from .snippets.client import SnippetsClient  # noqa: E402

            self._snippets = SnippetsClient(client_wrapper=self._client_wrapper)
        return self._snippets

    @property
    def subscriptions(self):
        if self._subscriptions is None:
            from .subscriptions.client import SubscriptionsClient  # noqa: E402

            self._subscriptions = SubscriptionsClient(client_wrapper=self._client_wrapper)
        return self._subscriptions

    @property
    def team_members(self):
        if self._team_members is None:
            from .team_members.client import TeamMembersClient  # noqa: E402

            self._team_members = TeamMembersClient(client_wrapper=self._client_wrapper)
        return self._team_members

    @property
    def team(self):
        if self._team is None:
            from .team.client import TeamClient  # noqa: E402

            self._team = TeamClient(client_wrapper=self._client_wrapper)
        return self._team

    @property
    def terminal(self):
        if self._terminal is None:
            from .terminal.client import TerminalClient  # noqa: E402

            self._terminal = TerminalClient(client_wrapper=self._client_wrapper)
        return self._terminal

    @property
    def transfer_orders(self):
        if self._transfer_orders is None:
            from .transfer_orders.client import TransferOrdersClient  # noqa: E402

            self._transfer_orders = TransferOrdersClient(client_wrapper=self._client_wrapper)
        return self._transfer_orders

    @property
    def vendors(self):
        if self._vendors is None:
            from .vendors.client import VendorsClient  # noqa: E402

            self._vendors = VendorsClient(client_wrapper=self._client_wrapper)
        return self._vendors

    @property
    def cash_drawers(self):
        if self._cash_drawers is None:
            from .cash_drawers.client import CashDrawersClient  # noqa: E402

            self._cash_drawers = CashDrawersClient(client_wrapper=self._client_wrapper)
        return self._cash_drawers

    @property
    def webhooks(self):
        if self._webhooks is None:
            from .webhooks.client import WebhooksClient  # noqa: E402

            self._webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
        return self._webhooks


class AsyncSquare:
    """
    Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.

    Parameters
    ----------
    base_url : typing.Optional[str]
        The base url to use for requests from the client.

    environment : SquareEnvironment
        The environment to use for requests from the client. from .environment import SquareEnvironment



        Defaults to SquareEnvironment.PRODUCTION



    token : typing.Optional[typing.Union[str, typing.Callable[[], str]]]
    headers : typing.Optional[typing.Dict[str, str]]
        Additional headers to send with every request.

    timeout : typing.Optional[float]
        The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.

    follow_redirects : typing.Optional[bool]
        Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.

    httpx_client : typing.Optional[httpx.AsyncClient]
        The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.

    version : typing.Optional[str]
    Examples
    --------
    from square import AsyncSquare

    client = AsyncSquare(
        token="YOUR_TOKEN",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: SquareEnvironment = SquareEnvironment.PRODUCTION,
        token: typing.Optional[typing.Union[str, typing.Callable[[], str]]] = os.getenv("SQUARE_TOKEN"),
        headers: typing.Optional[typing.Dict[str, str]] = None,
        timeout: typing.Optional[float] = None,
        follow_redirects: typing.Optional[bool] = True,
        httpx_client: typing.Optional[httpx.AsyncClient] = None,
        version: typing.Optional[str] = None,
    ):
        _defaulted_timeout = (
            timeout if timeout is not None else 60 if httpx_client is None else httpx_client.timeout.read
        )
        self._client_wrapper = AsyncClientWrapper(
            base_url=_get_base_url(base_url=base_url, environment=environment),
            token=token,
            headers=headers,
            httpx_client=httpx_client
            if httpx_client is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
            if follow_redirects is not None
            else httpx.AsyncClient(timeout=_defaulted_timeout),
            timeout=_defaulted_timeout,
            version=version,
        )
        self._o_auth: typing.Optional[AsyncOAuthClient] = None
        self._v1transactions: typing.Optional[AsyncV1TransactionsClient] = None
        self._apple_pay: typing.Optional[AsyncApplePayClient] = None
        self._bank_accounts: typing.Optional[AsyncBankAccountsClient] = None
        self._bookings: typing.Optional[AsyncBookingsClient] = None
        self._cards: typing.Optional[AsyncCardsClient] = None
        self._catalog: typing.Optional[AsyncCatalogClient] = None
        self._channels: typing.Optional[AsyncChannelsClient] = None
        self._customers: typing.Optional[AsyncCustomersClient] = None
        self._devices: typing.Optional[AsyncDevicesClient] = None
        self._disputes: typing.Optional[AsyncDisputesClient] = None
        self._employees: typing.Optional[AsyncEmployeesClient] = None
        self._events: typing.Optional[AsyncEventsClient] = None
        self._gift_cards: typing.Optional[AsyncGiftCardsClient] = None
        self._inventory: typing.Optional[AsyncInventoryClient] = None
        self._invoices: typing.Optional[AsyncInvoicesClient] = None
        self._labor: typing.Optional[AsyncLaborClient] = None
        self._locations: typing.Optional[AsyncLocationsClient] = None
        self._loyalty: typing.Optional[AsyncLoyaltyClient] = None
        self._merchants: typing.Optional[AsyncMerchantsClient] = None
        self._checkout: typing.Optional[AsyncCheckoutClient] = None
        self._orders: typing.Optional[AsyncOrdersClient] = None
        self._payments: typing.Optional[AsyncPaymentsClient] = None
        self._payouts: typing.Optional[AsyncPayoutsClient] = None
        self._refunds: typing.Optional[AsyncRefundsClient] = None
        self._sites: typing.Optional[AsyncSitesClient] = None
        self._snippets: typing.Optional[AsyncSnippetsClient] = None
        self._subscriptions: typing.Optional[AsyncSubscriptionsClient] = None
        self._team_members: typing.Optional[AsyncTeamMembersClient] = None
        self._team: typing.Optional[AsyncTeamClient] = None
        self._terminal: typing.Optional[AsyncTerminalClient] = None
        self._transfer_orders: typing.Optional[AsyncTransferOrdersClient] = None
        self._vendors: typing.Optional[AsyncVendorsClient] = None
        self._cash_drawers: typing.Optional[AsyncCashDrawersClient] = None
        self._webhooks: typing.Optional[AsyncWebhooksClient] = None

    @property
    def o_auth(self):
        if self._o_auth is None:
            from .o_auth.client import AsyncOAuthClient  # noqa: E402

            self._o_auth = AsyncOAuthClient(client_wrapper=self._client_wrapper)
        return self._o_auth

    @property
    def v1transactions(self):
        if self._v1transactions is None:
            from .v1transactions.client import AsyncV1TransactionsClient  # noqa: E402

            self._v1transactions = AsyncV1TransactionsClient(client_wrapper=self._client_wrapper)
        return self._v1transactions

    @property
    def apple_pay(self):
        if self._apple_pay is None:
            from .apple_pay.client import AsyncApplePayClient  # noqa: E402

            self._apple_pay = AsyncApplePayClient(client_wrapper=self._client_wrapper)
        return self._apple_pay

    @property
    def bank_accounts(self):
        if self._bank_accounts is None:
            from .bank_accounts.client import AsyncBankAccountsClient  # noqa: E402

            self._bank_accounts = AsyncBankAccountsClient(client_wrapper=self._client_wrapper)
        return self._bank_accounts

    @property
    def bookings(self):
        if self._bookings is None:
            from .bookings.client import AsyncBookingsClient  # noqa: E402

            self._bookings = AsyncBookingsClient(client_wrapper=self._client_wrapper)
        return self._bookings

    @property
    def cards(self):
        if self._cards is None:
            from .cards.client import AsyncCardsClient  # noqa: E402

            self._cards = AsyncCardsClient(client_wrapper=self._client_wrapper)
        return self._cards

    @property
    def catalog(self):
        if self._catalog is None:
            from .catalog.client import AsyncCatalogClient  # noqa: E402

            self._catalog = AsyncCatalogClient(client_wrapper=self._client_wrapper)
        return self._catalog

    @property
    def channels(self):
        if self._channels is None:
            from .channels.client import AsyncChannelsClient  # noqa: E402

            self._channels = AsyncChannelsClient(client_wrapper=self._client_wrapper)
        return self._channels

    @property
    def customers(self):
        if self._customers is None:
            from .customers.client import AsyncCustomersClient  # noqa: E402

            self._customers = AsyncCustomersClient(client_wrapper=self._client_wrapper)
        return self._customers

    @property
    def devices(self):
        if self._devices is None:
            from .devices.client import AsyncDevicesClient  # noqa: E402

            self._devices = AsyncDevicesClient(client_wrapper=self._client_wrapper)
        return self._devices

    @property
    def disputes(self):
        if self._disputes is None:
            from .disputes.client import AsyncDisputesClient  # noqa: E402

            self._disputes = AsyncDisputesClient(client_wrapper=self._client_wrapper)
        return self._disputes

    @property
    def employees(self):
        if self._employees is None:
            from .employees.client import AsyncEmployeesClient  # noqa: E402

            self._employees = AsyncEmployeesClient(client_wrapper=self._client_wrapper)
        return self._employees

    @property
    def events(self):
        if self._events is None:
            from .events.client import AsyncEventsClient  # noqa: E402

            self._events = AsyncEventsClient(client_wrapper=self._client_wrapper)
        return self._events

    @property
    def gift_cards(self):
        if self._gift_cards is None:
            from .gift_cards.client import AsyncGiftCardsClient  # noqa: E402

            self._gift_cards = AsyncGiftCardsClient(client_wrapper=self._client_wrapper)
        return self._gift_cards

    @property
    def inventory(self):
        if self._inventory is None:
            from .inventory.client import AsyncInventoryClient  # noqa: E402

            self._inventory = AsyncInventoryClient(client_wrapper=self._client_wrapper)
        return self._inventory

    @property
    def invoices(self):
        if self._invoices is None:
            from .invoices.client import AsyncInvoicesClient  # noqa: E402

            self._invoices = AsyncInvoicesClient(client_wrapper=self._client_wrapper)
        return self._invoices

    @property
    def labor(self):
        if self._labor is None:
            from .labor.client import AsyncLaborClient  # noqa: E402

            self._labor = AsyncLaborClient(client_wrapper=self._client_wrapper)
        return self._labor

    @property
    def locations(self):
        if self._locations is None:
            from .locations.client import AsyncLocationsClient  # noqa: E402

            self._locations = AsyncLocationsClient(client_wrapper=self._client_wrapper)
        return self._locations

    @property
    def loyalty(self):
        if self._loyalty is None:
            from .loyalty.client import AsyncLoyaltyClient  # noqa: E402

            self._loyalty = AsyncLoyaltyClient(client_wrapper=self._client_wrapper)
        return self._loyalty

    @property
    def merchants(self):
        if self._merchants is None:
            from .merchants.client import AsyncMerchantsClient  # noqa: E402

            self._merchants = AsyncMerchantsClient(client_wrapper=self._client_wrapper)
        return self._merchants

    @property
    def checkout(self):
        if self._checkout is None:
            from .checkout.client import AsyncCheckoutClient  # noqa: E402

            self._checkout = AsyncCheckoutClient(client_wrapper=self._client_wrapper)
        return self._checkout

    @property
    def orders(self):
        if self._orders is None:
            from .orders.client import AsyncOrdersClient  # noqa: E402

            self._orders = AsyncOrdersClient(client_wrapper=self._client_wrapper)
        return self._orders

    @property
    def payments(self):
        if self._payments is None:
            from .payments.client import AsyncPaymentsClient  # noqa: E402

            self._payments = AsyncPaymentsClient(client_wrapper=self._client_wrapper)
        return self._payments

    @property
    def payouts(self):
        if self._payouts is None:
            from .payouts.client import AsyncPayoutsClient  # noqa: E402

            self._payouts = AsyncPayoutsClient(client_wrapper=self._client_wrapper)
        return self._payouts

    @property
    def refunds(self):
        if self._refunds is None:
            from .refunds.client import AsyncRefundsClient  # noqa: E402

            self._refunds = AsyncRefundsClient(client_wrapper=self._client_wrapper)
        return self._refunds

    @property
    def sites(self):
        if self._sites is None:
            from .sites.client import AsyncSitesClient  # noqa: E402

            self._sites = AsyncSitesClient(client_wrapper=self._client_wrapper)
        return self._sites

    @property
    def snippets(self):
        if self._snippets is None:
            from .snippets.client import AsyncSnippetsClient  # noqa: E402

            self._snippets = AsyncSnippetsClient(client_wrapper=self._client_wrapper)
        return self._snippets

    @property
    def subscriptions(self):
        if self._subscriptions is None:
            from .subscriptions.client import AsyncSubscriptionsClient  # noqa: E402

            self._subscriptions = AsyncSubscriptionsClient(client_wrapper=self._client_wrapper)
        return self._subscriptions

    @property
    def team_members(self):
        if self._team_members is None:
            from .team_members.client import AsyncTeamMembersClient  # noqa: E402

            self._team_members = AsyncTeamMembersClient(client_wrapper=self._client_wrapper)
        return self._team_members

    @property
    def team(self):
        if self._team is None:
            from .team.client import AsyncTeamClient  # noqa: E402

            self._team = AsyncTeamClient(client_wrapper=self._client_wrapper)
        return self._team

    @property
    def terminal(self):
        if self._terminal is None:
            from .terminal.client import AsyncTerminalClient  # noqa: E402

            self._terminal = AsyncTerminalClient(client_wrapper=self._client_wrapper)
        return self._terminal

    @property
    def transfer_orders(self):
        if self._transfer_orders is None:
            from .transfer_orders.client import AsyncTransferOrdersClient  # noqa: E402

            self._transfer_orders = AsyncTransferOrdersClient(client_wrapper=self._client_wrapper)
        return self._transfer_orders

    @property
    def vendors(self):
        if self._vendors is None:
            from .vendors.client import AsyncVendorsClient  # noqa: E402

            self._vendors = AsyncVendorsClient(client_wrapper=self._client_wrapper)
        return self._vendors

    @property
    def cash_drawers(self):
        if self._cash_drawers is None:
            from .cash_drawers.client import AsyncCashDrawersClient  # noqa: E402

            self._cash_drawers = AsyncCashDrawersClient(client_wrapper=self._client_wrapper)
        return self._cash_drawers

    @property
    def webhooks(self):
        if self._webhooks is None:
            from .webhooks.client import AsyncWebhooksClient  # noqa: E402

            self._webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
        return self._webhooks


def _get_base_url(*, base_url: typing.Optional[str] = None, environment: SquareEnvironment) -> str:
    if base_url is not None:
        return base_url
    elif environment is not None:
        return environment.value
    else:
        raise Exception("Please pass in either base_url or environment to construct the client")
