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

import typing

import httpx
from .bill.client import AsyncBillClient, BillClient
from .boarding.client import AsyncBoardingClient, BoardingClient
from .charge_backs.client import AsyncChargeBacksClient, ChargeBacksClient
from .check_capture.client import AsyncCheckCaptureClient, CheckCaptureClient
from .cloud.client import AsyncCloudClient, CloudClient
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .customer.client import AsyncCustomerClient, CustomerClient
from .environment import payabliEnvironment
from .export.client import AsyncExportClient, ExportClient
from .hosted_payment_pages.client import AsyncHostedPaymentPagesClient, HostedPaymentPagesClient
from .import_.client import AsyncImportClient, ImportClient
from .invoice.client import AsyncInvoiceClient, InvoiceClient
from .line_item.client import AsyncLineItemClient, LineItemClient
from .money_in.client import AsyncMoneyInClient, MoneyInClient
from .money_out.client import AsyncMoneyOutClient, MoneyOutClient
from .notification.client import AsyncNotificationClient, NotificationClient
from .ocr.client import AsyncOcrClient, OcrClient
from .organization.client import AsyncOrganizationClient, OrganizationClient
from .payment_link.client import AsyncPaymentLinkClient, PaymentLinkClient
from .payment_method_domain.client import AsyncPaymentMethodDomainClient, PaymentMethodDomainClient
from .paypoint.client import AsyncPaypointClient, PaypointClient
from .query.client import AsyncQueryClient, QueryClient
from .statistic.client import AsyncStatisticClient, StatisticClient
from .subscription.client import AsyncSubscriptionClient, SubscriptionClient
from .templates.client import AsyncTemplatesClient, TemplatesClient
from .token_storage.client import AsyncTokenStorageClient, TokenStorageClient
from .user.client import AsyncUserClient, UserClient
from .vendor.client import AsyncVendorClient, VendorClient
from .wallet.client import AsyncWalletClient, WalletClient


class payabli:
    """
    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 : payabliEnvironment
        The environment to use for requests from the client. from .environment import payabliEnvironment



        Defaults to payabliEnvironment.SANDBOX



    api_key : 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.

    Examples
    --------
    from payabli import payabli

    client = payabli(
        api_key="YOUR_API_KEY",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: payabliEnvironment = payabliEnvironment.SANDBOX,
        api_key: str,
        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,
    ):
        _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),
            api_key=api_key,
            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,
        )
        self.bill = BillClient(client_wrapper=self._client_wrapper)
        self.boarding = BoardingClient(client_wrapper=self._client_wrapper)
        self.charge_backs = ChargeBacksClient(client_wrapper=self._client_wrapper)
        self.check_capture = CheckCaptureClient(client_wrapper=self._client_wrapper)
        self.cloud = CloudClient(client_wrapper=self._client_wrapper)
        self.customer = CustomerClient(client_wrapper=self._client_wrapper)
        self.export = ExportClient(client_wrapper=self._client_wrapper)
        self.hosted_payment_pages = HostedPaymentPagesClient(client_wrapper=self._client_wrapper)
        self.import_ = ImportClient(client_wrapper=self._client_wrapper)
        self.invoice = InvoiceClient(client_wrapper=self._client_wrapper)
        self.line_item = LineItemClient(client_wrapper=self._client_wrapper)
        self.money_in = MoneyInClient(client_wrapper=self._client_wrapper)
        self.money_out = MoneyOutClient(client_wrapper=self._client_wrapper)
        self.notification = NotificationClient(client_wrapper=self._client_wrapper)
        self.ocr = OcrClient(client_wrapper=self._client_wrapper)
        self.organization = OrganizationClient(client_wrapper=self._client_wrapper)
        self.payment_link = PaymentLinkClient(client_wrapper=self._client_wrapper)
        self.payment_method_domain = PaymentMethodDomainClient(client_wrapper=self._client_wrapper)
        self.paypoint = PaypointClient(client_wrapper=self._client_wrapper)
        self.query = QueryClient(client_wrapper=self._client_wrapper)
        self.statistic = StatisticClient(client_wrapper=self._client_wrapper)
        self.subscription = SubscriptionClient(client_wrapper=self._client_wrapper)
        self.templates = TemplatesClient(client_wrapper=self._client_wrapper)
        self.token_storage = TokenStorageClient(client_wrapper=self._client_wrapper)
        self.user = UserClient(client_wrapper=self._client_wrapper)
        self.vendor = VendorClient(client_wrapper=self._client_wrapper)
        self.wallet = WalletClient(client_wrapper=self._client_wrapper)


class Asyncpayabli:
    """
    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 : payabliEnvironment
        The environment to use for requests from the client. from .environment import payabliEnvironment



        Defaults to payabliEnvironment.SANDBOX



    api_key : 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.

    Examples
    --------
    from payabli import Asyncpayabli

    client = Asyncpayabli(
        api_key="YOUR_API_KEY",
    )
    """

    def __init__(
        self,
        *,
        base_url: typing.Optional[str] = None,
        environment: payabliEnvironment = payabliEnvironment.SANDBOX,
        api_key: str,
        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,
    ):
        _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),
            api_key=api_key,
            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,
        )
        self.bill = AsyncBillClient(client_wrapper=self._client_wrapper)
        self.boarding = AsyncBoardingClient(client_wrapper=self._client_wrapper)
        self.charge_backs = AsyncChargeBacksClient(client_wrapper=self._client_wrapper)
        self.check_capture = AsyncCheckCaptureClient(client_wrapper=self._client_wrapper)
        self.cloud = AsyncCloudClient(client_wrapper=self._client_wrapper)
        self.customer = AsyncCustomerClient(client_wrapper=self._client_wrapper)
        self.export = AsyncExportClient(client_wrapper=self._client_wrapper)
        self.hosted_payment_pages = AsyncHostedPaymentPagesClient(client_wrapper=self._client_wrapper)
        self.import_ = AsyncImportClient(client_wrapper=self._client_wrapper)
        self.invoice = AsyncInvoiceClient(client_wrapper=self._client_wrapper)
        self.line_item = AsyncLineItemClient(client_wrapper=self._client_wrapper)
        self.money_in = AsyncMoneyInClient(client_wrapper=self._client_wrapper)
        self.money_out = AsyncMoneyOutClient(client_wrapper=self._client_wrapper)
        self.notification = AsyncNotificationClient(client_wrapper=self._client_wrapper)
        self.ocr = AsyncOcrClient(client_wrapper=self._client_wrapper)
        self.organization = AsyncOrganizationClient(client_wrapper=self._client_wrapper)
        self.payment_link = AsyncPaymentLinkClient(client_wrapper=self._client_wrapper)
        self.payment_method_domain = AsyncPaymentMethodDomainClient(client_wrapper=self._client_wrapper)
        self.paypoint = AsyncPaypointClient(client_wrapper=self._client_wrapper)
        self.query = AsyncQueryClient(client_wrapper=self._client_wrapper)
        self.statistic = AsyncStatisticClient(client_wrapper=self._client_wrapper)
        self.subscription = AsyncSubscriptionClient(client_wrapper=self._client_wrapper)
        self.templates = AsyncTemplatesClient(client_wrapper=self._client_wrapper)
        self.token_storage = AsyncTokenStorageClient(client_wrapper=self._client_wrapper)
        self.user = AsyncUserClient(client_wrapper=self._client_wrapper)
        self.vendor = AsyncVendorClient(client_wrapper=self._client_wrapper)
        self.wallet = AsyncWalletClient(client_wrapper=self._client_wrapper)


def _get_base_url(*, base_url: typing.Optional[str] = None, environment: payabliEnvironment) -> 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")
