# 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 ..types.push_subscribe_response import PushSubscribeResponse
from ..types.push_subscription_list_response import PushSubscriptionListResponse
from .raw_client import AsyncRawNotificationsClient, RawNotificationsClient
from .types.push_subscribe_request_device_type import PushSubscribeRequestDeviceType

# this is used as the default value for optional parameters
OMIT = typing.cast(typing.Any, ...)


class NotificationsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawNotificationsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawNotificationsClient
        """
        return self._raw_client

    def test_push(
        self, *, device_token: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Send a test FCM data message to a specific device token. Not available in production. Verifies the full chain: token -> Firebase -> service worker.

        Parameters
        ----------
        device_token : str
            FCM device token to send the test message to

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.notifications.test_push(
            device_token="device_token",
        )
        """
        _response = self._raw_client.test_push(device_token=device_token, request_options=request_options)
        return _response.data

    def subscribe_push(
        self,
        *,
        device_token: str,
        device_type: PushSubscribeRequestDeviceType,
        device_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PushSubscribeResponse:
        """
        Register an FCM device token to receive push notifications when background responses complete. Duplicate tokens are upserted.

        Parameters
        ----------
        device_token : str
            FCM registration token from the client SDK

        device_type : PushSubscribeRequestDeviceType
            Device platform

        device_name : typing.Optional[str]
            User-friendly device name

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

        Returns
        -------
        PushSubscribeResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.notifications.subscribe_push(
            device_token="device_token",
            device_type="web",
        )
        """
        _response = self._raw_client.subscribe_push(
            device_token=device_token, device_type=device_type, device_name=device_name, request_options=request_options
        )
        return _response.data

    def unsubscribe_push(
        self, *, device_token: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Remove an FCM device token so the device no longer receives notifications.

        Parameters
        ----------
        device_token : str
            FCM token to unregister

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

        Returns
        -------
        typing.Dict[str, typing.Any]
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.notifications.unsubscribe_push(
            device_token="device_token",
        )
        """
        _response = self._raw_client.unsubscribe_push(device_token=device_token, request_options=request_options)
        return _response.data

    def list_subscriptions(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PushSubscriptionListResponse:
        """
        List all active push notification subscriptions for the authenticated user.

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

        Returns
        -------
        PushSubscriptionListResponse
            Successful Response

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

        client = Aitronos(
            api_key="YOUR_API_KEY",
            token="YOUR_TOKEN",
        )
        client.notifications.list_subscriptions()
        """
        _response = self._raw_client.list_subscriptions(request_options=request_options)
        return _response.data


class AsyncNotificationsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawNotificationsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawNotificationsClient
        """
        return self._raw_client

    async def test_push(
        self, *, device_token: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Send a test FCM data message to a specific device token. Not available in production. Verifies the full chain: token -> Firebase -> service worker.

        Parameters
        ----------
        device_token : str
            FCM device token to send the test message to

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

        Returns
        -------
        typing.Dict[str, 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.notifications.test_push(
                device_token="device_token",
            )


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

    async def subscribe_push(
        self,
        *,
        device_token: str,
        device_type: PushSubscribeRequestDeviceType,
        device_name: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> PushSubscribeResponse:
        """
        Register an FCM device token to receive push notifications when background responses complete. Duplicate tokens are upserted.

        Parameters
        ----------
        device_token : str
            FCM registration token from the client SDK

        device_type : PushSubscribeRequestDeviceType
            Device platform

        device_name : typing.Optional[str]
            User-friendly device name

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

        Returns
        -------
        PushSubscribeResponse
            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.notifications.subscribe_push(
                device_token="device_token",
                device_type="web",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.subscribe_push(
            device_token=device_token, device_type=device_type, device_name=device_name, request_options=request_options
        )
        return _response.data

    async def unsubscribe_push(
        self, *, device_token: str, request_options: typing.Optional[RequestOptions] = None
    ) -> typing.Dict[str, typing.Any]:
        """
        Remove an FCM device token so the device no longer receives notifications.

        Parameters
        ----------
        device_token : str
            FCM token to unregister

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

        Returns
        -------
        typing.Dict[str, 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.notifications.unsubscribe_push(
                device_token="device_token",
            )


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

    async def list_subscriptions(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PushSubscriptionListResponse:
        """
        List all active push notification subscriptions for the authenticated user.

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

        Returns
        -------
        PushSubscriptionListResponse
            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.notifications.list_subscriptions()


        asyncio.run(main())
        """
        _response = await self._raw_client.list_subscriptions(request_options=request_options)
        return _response.data
