# 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 AsyncRawAtomsClient, RawAtomsClient

if typing.TYPE_CHECKING:
    from .agent_templates.client import AgentTemplatesClient, AsyncAgentTemplatesClient
    from .agents.client import AgentsClient, AsyncAgentsClient
    from .audience.client import AsyncAudienceClient, AudienceClient
    from .calls.client import AsyncCallsClient, CallsClient
    from .campaigns.client import AsyncCampaignsClient, CampaignsClient
    from .knowledge_base.client import AsyncKnowledgeBaseClient, KnowledgeBaseClient
    from .logs.client import AsyncLogsClient, LogsClient
    from .organization.client import AsyncOrganizationClient, OrganizationClient
    from .phone_numbers.client import AsyncPhoneNumbersClient, PhoneNumbersClient
    from .user.client import AsyncUserClient, UserClient
    from .webhooks.client import AsyncWebhooksClient, WebhooksClient
    from .workflows.client import AsyncWorkflowsClient, WorkflowsClient


class AtomsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawAtomsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._user: typing.Optional[UserClient] = None
        self._organization: typing.Optional[OrganizationClient] = None
        self._agent_templates: typing.Optional[AgentTemplatesClient] = None
        self._agents: typing.Optional[AgentsClient] = None
        self._workflows: typing.Optional[WorkflowsClient] = None
        self._logs: typing.Optional[LogsClient] = None
        self._calls: typing.Optional[CallsClient] = None
        self._campaigns: typing.Optional[CampaignsClient] = None
        self._knowledge_base: typing.Optional[KnowledgeBaseClient] = None
        self._phone_numbers: typing.Optional[PhoneNumbersClient] = None
        self._webhooks: typing.Optional[WebhooksClient] = None
        self._audience: typing.Optional[AudienceClient] = None

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

        Returns
        -------
        RawAtomsClient
        """
        return self._raw_client

    @property
    def user(self):
        if self._user is None:
            from .user.client import UserClient  # noqa: E402

            self._user = UserClient(client_wrapper=self._client_wrapper)
        return self._user

    @property
    def organization(self):
        if self._organization is None:
            from .organization.client import OrganizationClient  # noqa: E402

            self._organization = OrganizationClient(client_wrapper=self._client_wrapper)
        return self._organization

    @property
    def agent_templates(self):
        if self._agent_templates is None:
            from .agent_templates.client import AgentTemplatesClient  # noqa: E402

            self._agent_templates = AgentTemplatesClient(client_wrapper=self._client_wrapper)
        return self._agent_templates

    @property
    def agents(self):
        if self._agents is None:
            from .agents.client import AgentsClient  # noqa: E402

            self._agents = AgentsClient(client_wrapper=self._client_wrapper)
        return self._agents

    @property
    def workflows(self):
        if self._workflows is None:
            from .workflows.client import WorkflowsClient  # noqa: E402

            self._workflows = WorkflowsClient(client_wrapper=self._client_wrapper)
        return self._workflows

    @property
    def logs(self):
        if self._logs is None:
            from .logs.client import LogsClient  # noqa: E402

            self._logs = LogsClient(client_wrapper=self._client_wrapper)
        return self._logs

    @property
    def calls(self):
        if self._calls is None:
            from .calls.client import CallsClient  # noqa: E402

            self._calls = CallsClient(client_wrapper=self._client_wrapper)
        return self._calls

    @property
    def campaigns(self):
        if self._campaigns is None:
            from .campaigns.client import CampaignsClient  # noqa: E402

            self._campaigns = CampaignsClient(client_wrapper=self._client_wrapper)
        return self._campaigns

    @property
    def knowledge_base(self):
        if self._knowledge_base is None:
            from .knowledge_base.client import KnowledgeBaseClient  # noqa: E402

            self._knowledge_base = KnowledgeBaseClient(client_wrapper=self._client_wrapper)
        return self._knowledge_base

    @property
    def phone_numbers(self):
        if self._phone_numbers is None:
            from .phone_numbers.client import PhoneNumbersClient  # noqa: E402

            self._phone_numbers = PhoneNumbersClient(client_wrapper=self._client_wrapper)
        return self._phone_numbers

    @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

    @property
    def audience(self):
        if self._audience is None:
            from .audience.client import AudienceClient  # noqa: E402

            self._audience = AudienceClient(client_wrapper=self._client_wrapper)
        return self._audience


class AsyncAtomsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawAtomsClient(client_wrapper=client_wrapper)
        self._client_wrapper = client_wrapper
        self._user: typing.Optional[AsyncUserClient] = None
        self._organization: typing.Optional[AsyncOrganizationClient] = None
        self._agent_templates: typing.Optional[AsyncAgentTemplatesClient] = None
        self._agents: typing.Optional[AsyncAgentsClient] = None
        self._workflows: typing.Optional[AsyncWorkflowsClient] = None
        self._logs: typing.Optional[AsyncLogsClient] = None
        self._calls: typing.Optional[AsyncCallsClient] = None
        self._campaigns: typing.Optional[AsyncCampaignsClient] = None
        self._knowledge_base: typing.Optional[AsyncKnowledgeBaseClient] = None
        self._phone_numbers: typing.Optional[AsyncPhoneNumbersClient] = None
        self._webhooks: typing.Optional[AsyncWebhooksClient] = None
        self._audience: typing.Optional[AsyncAudienceClient] = None

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

        Returns
        -------
        AsyncRawAtomsClient
        """
        return self._raw_client

    @property
    def user(self):
        if self._user is None:
            from .user.client import AsyncUserClient  # noqa: E402

            self._user = AsyncUserClient(client_wrapper=self._client_wrapper)
        return self._user

    @property
    def organization(self):
        if self._organization is None:
            from .organization.client import AsyncOrganizationClient  # noqa: E402

            self._organization = AsyncOrganizationClient(client_wrapper=self._client_wrapper)
        return self._organization

    @property
    def agent_templates(self):
        if self._agent_templates is None:
            from .agent_templates.client import AsyncAgentTemplatesClient  # noqa: E402

            self._agent_templates = AsyncAgentTemplatesClient(client_wrapper=self._client_wrapper)
        return self._agent_templates

    @property
    def agents(self):
        if self._agents is None:
            from .agents.client import AsyncAgentsClient  # noqa: E402

            self._agents = AsyncAgentsClient(client_wrapper=self._client_wrapper)
        return self._agents

    @property
    def workflows(self):
        if self._workflows is None:
            from .workflows.client import AsyncWorkflowsClient  # noqa: E402

            self._workflows = AsyncWorkflowsClient(client_wrapper=self._client_wrapper)
        return self._workflows

    @property
    def logs(self):
        if self._logs is None:
            from .logs.client import AsyncLogsClient  # noqa: E402

            self._logs = AsyncLogsClient(client_wrapper=self._client_wrapper)
        return self._logs

    @property
    def calls(self):
        if self._calls is None:
            from .calls.client import AsyncCallsClient  # noqa: E402

            self._calls = AsyncCallsClient(client_wrapper=self._client_wrapper)
        return self._calls

    @property
    def campaigns(self):
        if self._campaigns is None:
            from .campaigns.client import AsyncCampaignsClient  # noqa: E402

            self._campaigns = AsyncCampaignsClient(client_wrapper=self._client_wrapper)
        return self._campaigns

    @property
    def knowledge_base(self):
        if self._knowledge_base is None:
            from .knowledge_base.client import AsyncKnowledgeBaseClient  # noqa: E402

            self._knowledge_base = AsyncKnowledgeBaseClient(client_wrapper=self._client_wrapper)
        return self._knowledge_base

    @property
    def phone_numbers(self):
        if self._phone_numbers is None:
            from .phone_numbers.client import AsyncPhoneNumbersClient  # noqa: E402

            self._phone_numbers = AsyncPhoneNumbersClient(client_wrapper=self._client_wrapper)
        return self._phone_numbers

    @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

    @property
    def audience(self):
        if self._audience is None:
            from .audience.client import AsyncAudienceClient  # noqa: E402

            self._audience = AsyncAudienceClient(client_wrapper=self._client_wrapper)
        return self._audience
