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

from __future__ import annotations

import typing

from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .raw_client import AsyncRawBillingClient, RawBillingClient

if typing.TYPE_CHECKING:
    from .balances.client import AsyncBalancesClient, BalancesClient
    from .breakdown.client import AsyncBreakdownClient, BreakdownClient
    from .fields.client import AsyncFieldsClient, FieldsClient
    from .purchases.client import AsyncPurchasesClient, PurchasesClient


class BillingClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawBillingClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._balances: typing.Optional[BalancesClient] = None
        self._breakdown: typing.Optional[BreakdownClient] = None
        self._fields: typing.Optional[FieldsClient] = None
        self._purchases: typing.Optional[PurchasesClient] = None

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

        Returns
        -------
        RawBillingClient
        """
        return self._raw_client

    @property
    def balances(self):
        if self._balances is None:
            from .balances.client import BalancesClient  # noqa: E402

            self._balances = BalancesClient(client_wrapper=self._client_wrapper)
        return self._balances

    @property
    def breakdown(self):
        if self._breakdown is None:
            from .breakdown.client import BreakdownClient  # noqa: E402

            self._breakdown = BreakdownClient(client_wrapper=self._client_wrapper)
        return self._breakdown

    @property
    def fields(self):
        if self._fields is None:
            from .fields.client import FieldsClient  # noqa: E402

            self._fields = FieldsClient(client_wrapper=self._client_wrapper)
        return self._fields

    @property
    def purchases(self):
        if self._purchases is None:
            from .purchases.client import PurchasesClient  # noqa: E402

            self._purchases = PurchasesClient(client_wrapper=self._client_wrapper)
        return self._purchases


class AsyncBillingClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawBillingClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._balances: typing.Optional[AsyncBalancesClient] = None
        self._breakdown: typing.Optional[AsyncBreakdownClient] = None
        self._fields: typing.Optional[AsyncFieldsClient] = None
        self._purchases: typing.Optional[AsyncPurchasesClient] = None

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

        Returns
        -------
        AsyncRawBillingClient
        """
        return self._raw_client

    @property
    def balances(self):
        if self._balances is None:
            from .balances.client import AsyncBalancesClient  # noqa: E402

            self._balances = AsyncBalancesClient(client_wrapper=self._client_wrapper)
        return self._balances

    @property
    def breakdown(self):
        if self._breakdown is None:
            from .breakdown.client import AsyncBreakdownClient  # noqa: E402

            self._breakdown = AsyncBreakdownClient(client_wrapper=self._client_wrapper)
        return self._breakdown

    @property
    def fields(self):
        if self._fields is None:
            from .fields.client import AsyncFieldsClient  # noqa: E402

            self._fields = AsyncFieldsClient(client_wrapper=self._client_wrapper)
        return self._fields

    @property
    def purchases(self):
        if self._purchases is None:
            from .purchases.client import AsyncPurchasesClient  # noqa: E402

            self._purchases = AsyncPurchasesClient(client_wrapper=self._client_wrapper)
        return self._purchases
