# 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.file import File
from ..types.notification_query_record import NotificationQueryRecord
from ..types.payabli_api_response_notifications import PayabliApiResponseNotifications
from .raw_client import AsyncRawNotificationClient, RawNotificationClient
from .types.add_notification_request import AddNotificationRequest
from .types.update_notification_request import UpdateNotificationRequest

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


class NotificationClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawNotificationClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawNotificationClient
        """
        return self._raw_client

    def add_notification(
        self, *, request: AddNotificationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseNotifications:
        """
        Create a new notification or autogenerated report.

        Parameters
        ----------
        request : AddNotificationRequest

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

        Returns
        -------
        PayabliApiResponseNotifications
            Success

        Examples
        --------
        from payabli import (
            NotificationStandardRequest,
            NotificationStandardRequestContent,
            payabli,
        )

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.notification.add_notification(
            request=NotificationStandardRequest(
                content=NotificationStandardRequestContent(
                    event_type="CreatedApplication",
                ),
                frequency="untilcancelled",
                method="web",
                owner_id="236",
                owner_type=0,
                status=1,
                target="https://webhook.site/2871b8f8-edc7-441a-b376-98d8c8e33275",
            ),
        )
        """
        _response = self._raw_client.add_notification(request=request, request_options=request_options)
        return _response.data

    def delete_notification(
        self, n_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseNotifications:
        """
        Deletes a single notification or autogenerated report.

        Parameters
        ----------
        n_id : str
            Notification ID.

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

        Returns
        -------
        PayabliApiResponseNotifications
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.notification.delete_notification(
            n_id="1717",
        )
        """
        _response = self._raw_client.delete_notification(n_id, request_options=request_options)
        return _response.data

    def get_notification(
        self, n_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> NotificationQueryRecord:
        """
        Retrieves a single notification or autogenerated report's details.

        Parameters
        ----------
        n_id : str
            Notification ID.

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

        Returns
        -------
        NotificationQueryRecord
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.notification.get_notification(
            n_id="1717",
        )
        """
        _response = self._raw_client.get_notification(n_id, request_options=request_options)
        return _response.data

    def update_notification(
        self, n_id: str, *, request: UpdateNotificationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseNotifications:
        """
        Update a notification or autogenerated report.

        Parameters
        ----------
        n_id : str
            Notification ID.

        request : UpdateNotificationRequest

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

        Returns
        -------
        PayabliApiResponseNotifications
            Success

        Examples
        --------
        from payabli import (
            NotificationStandardRequest,
            NotificationStandardRequestContent,
            payabli,
        )

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.notification.update_notification(
            n_id="1717",
            request=NotificationStandardRequest(
                content=NotificationStandardRequestContent(
                    event_type="ApprovedPayment",
                ),
                frequency="untilcancelled",
                method="email",
                owner_id="136",
                owner_type=0,
                status=1,
                target="newemail@email.com",
            ),
        )
        """
        _response = self._raw_client.update_notification(n_id, request=request, request_options=request_options)
        return _response.data

    def get_report_file(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> File:
        """
        Gets a copy of a generated report by ID.

        Parameters
        ----------
        id : int
            Report ID

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

        Returns
        -------
        File
            Success

        Examples
        --------
        from payabli import payabli

        client = payabli(
            api_key="YOUR_API_KEY",
        )
        client.notification.get_report_file(
            id=1000000,
        )
        """
        _response = self._raw_client.get_report_file(id, request_options=request_options)
        return _response.data


class AsyncNotificationClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawNotificationClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawNotificationClient
        """
        return self._raw_client

    async def add_notification(
        self, *, request: AddNotificationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseNotifications:
        """
        Create a new notification or autogenerated report.

        Parameters
        ----------
        request : AddNotificationRequest

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

        Returns
        -------
        PayabliApiResponseNotifications
            Success

        Examples
        --------
        import asyncio

        from payabli import (
            Asyncpayabli,
            NotificationStandardRequest,
            NotificationStandardRequestContent,
        )

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.notification.add_notification(
                request=NotificationStandardRequest(
                    content=NotificationStandardRequestContent(
                        event_type="CreatedApplication",
                    ),
                    frequency="untilcancelled",
                    method="web",
                    owner_id="236",
                    owner_type=0,
                    status=1,
                    target="https://webhook.site/2871b8f8-edc7-441a-b376-98d8c8e33275",
                ),
            )


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

    async def delete_notification(
        self, n_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseNotifications:
        """
        Deletes a single notification or autogenerated report.

        Parameters
        ----------
        n_id : str
            Notification ID.

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

        Returns
        -------
        PayabliApiResponseNotifications
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.notification.delete_notification(
                n_id="1717",
            )


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

    async def get_notification(
        self, n_id: str, *, request_options: typing.Optional[RequestOptions] = None
    ) -> NotificationQueryRecord:
        """
        Retrieves a single notification or autogenerated report's details.

        Parameters
        ----------
        n_id : str
            Notification ID.

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

        Returns
        -------
        NotificationQueryRecord
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.notification.get_notification(
                n_id="1717",
            )


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

    async def update_notification(
        self, n_id: str, *, request: UpdateNotificationRequest, request_options: typing.Optional[RequestOptions] = None
    ) -> PayabliApiResponseNotifications:
        """
        Update a notification or autogenerated report.

        Parameters
        ----------
        n_id : str
            Notification ID.

        request : UpdateNotificationRequest

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

        Returns
        -------
        PayabliApiResponseNotifications
            Success

        Examples
        --------
        import asyncio

        from payabli import (
            Asyncpayabli,
            NotificationStandardRequest,
            NotificationStandardRequestContent,
        )

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.notification.update_notification(
                n_id="1717",
                request=NotificationStandardRequest(
                    content=NotificationStandardRequestContent(
                        event_type="ApprovedPayment",
                    ),
                    frequency="untilcancelled",
                    method="email",
                    owner_id="136",
                    owner_type=0,
                    status=1,
                    target="newemail@email.com",
                ),
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.update_notification(n_id, request=request, request_options=request_options)
        return _response.data

    async def get_report_file(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> File:
        """
        Gets a copy of a generated report by ID.

        Parameters
        ----------
        id : int
            Report ID

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

        Returns
        -------
        File
            Success

        Examples
        --------
        import asyncio

        from payabli import Asyncpayabli

        client = Asyncpayabli(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.notification.get_report_file(
                id=1000000,
            )


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