# 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.

        Verifies the HMAC-SHA256 signature, extracts event data, and dispatches
        matching trigger subscriptions to FlowPlate flows in the background.

        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

    def generic_provider_webhook(
        self, provider: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Generic webhook ingress. Extracts event_type and connection_id using a provider-specific normalizer, then dispatches matching trigger subscriptions to FlowPlate. Supported providers with built-in normalizers: freshdesk, github, stripe, shopify. Unknown providers use a generic normalizer that reads event_type and connection_id from the JSON body.

        Parameters
        ----------
        provider : str
            Provider name (e.g., 'freshdesk', 'github')

        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.generic_provider_webhook(
            provider="provider",
        )
        """
        _response = self._raw_client.generic_provider_webhook(provider, 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.

        Verifies the HMAC-SHA256 signature, extracts event data, and dispatches
        matching trigger subscriptions to FlowPlate flows in the background.

        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

    async def generic_provider_webhook(
        self, provider: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Any:
        """
        Generic webhook ingress. Extracts event_type and connection_id using a provider-specific normalizer, then dispatches matching trigger subscriptions to FlowPlate. Supported providers with built-in normalizers: freshdesk, github, stripe, shopify. Unknown providers use a generic normalizer that reads event_type and connection_id from the JSON body.

        Parameters
        ----------
        provider : str
            Provider name (e.g., 'freshdesk', 'github')

        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.generic_provider_webhook(
                provider="provider",
            )


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