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

import typing

from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from ..core.request_options import RequestOptions
from .raw_client import AsyncRawWebhooksClient, RawWebhooksClient


class WebhooksClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawWebhooksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawWebhooksClient
        """
        return self._raw_client

    def connector_webhook(
        self,
        *,
        composio_signature: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Receive and process connector trigger webhooks.

        The platform sends webhooks for trigger events like:
        - New email received (Gmail)
        - New calendar event (Google Calendar)
        - New message in channel (Slack)
        - New issue created (GitHub)
        - And 500+ other triggers

        The webhook payload contains:
        - trigger_id: Unique identifier for the trigger
        - trigger_name: Name of the trigger (e.g., "gmail_new_email")
        - connection_id: ID of the connected account
        - payload: Event-specific data

        Security:
        - Signature verification using HMAC-SHA256

        Returns:
            200: Webhook received and processed successfully
            401: Invalid signature
            422: Invalid payload
            500: Processing error

        Parameters
        ----------
        composio_signature : typing.Optional[str]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        from aitronos import Aitronos

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.webhooks.connector_webhook()
        """
        _response = self._raw_client.connector_webhook(
            composio_signature=composio_signature, request_options=request_options
        )
        return _response.data


class AsyncWebhooksClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawWebhooksClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawWebhooksClient
        """
        return self._raw_client

    async def connector_webhook(
        self,
        *,
        composio_signature: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> typing.Any:
        """
        Receive and process connector trigger webhooks.

        The platform sends webhooks for trigger events like:
        - New email received (Gmail)
        - New calendar event (Google Calendar)
        - New message in channel (Slack)
        - New issue created (GitHub)
        - And 500+ other triggers

        The webhook payload contains:
        - trigger_id: Unique identifier for the trigger
        - trigger_name: Name of the trigger (e.g., "gmail_new_email")
        - connection_id: ID of the connected account
        - payload: Event-specific data

        Security:
        - Signature verification using HMAC-SHA256

        Returns:
            200: Webhook received and processed successfully
            401: Invalid signature
            422: Invalid payload
            500: Processing error

        Parameters
        ----------
        composio_signature : typing.Optional[str]

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

        Returns
        -------
        typing.Any
            Successful Response

        Examples
        --------
        import asyncio

        from aitronos import AsyncAitronos

        client = AsyncAitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.webhooks.connector_webhook()


        asyncio.run(main())
        """
        _response = await self._raw_client.connector_webhook(
            composio_signature=composio_signature, request_options=request_options
        )
        return _response.data
