# 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.list_scheduled_messages_response import ListScheduledMessagesResponse
from .raw_client import AsyncRawSchedulesClient, RawSchedulesClient
from .types.list_scheduled_messages_request_schedule_type import ListScheduledMessagesRequestScheduleType
from .types.list_scheduled_messages_request_status import ListScheduledMessagesRequestStatus

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


class SchedulesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSchedulesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSchedulesClient
        """
        return self._raw_client

    def list(
        self,
        *,
        page_index: typing.Optional[int] = OMIT,
        page_size: typing.Optional[int] = OMIT,
        status: typing.Optional[ListScheduledMessagesRequestStatus] = OMIT,
        schedule_type: typing.Optional[ListScheduledMessagesRequestScheduleType] = OMIT,
        content: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListScheduledMessagesResponse:
        """
        List all scheduled messages with optional filtering and pagination. Results are sorted by creation date, newest first.

        Parameters
        ----------
        page_index : typing.Optional[int]

        page_size : typing.Optional[int]

        status : typing.Optional[ListScheduledMessagesRequestStatus]

        schedule_type : typing.Optional[ListScheduledMessagesRequestScheduleType]
            Filter by schedule type — "MESSAGE" for individual messages, "BLAST" for bulk sends.

        content : typing.Optional[str]
            Search scheduled message content (partial match, case-insensitive).

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

        Returns
        -------
        ListScheduledMessagesResponse
            Returns paginated list of scheduled messages.

        Examples
        --------
        from rcs import Pinnacle

        client = Pinnacle(
            api_key="YOUR_API_KEY",
        )
        client.messages.schedules.list()
        """
        _response = self._raw_client.list(
            page_index=page_index,
            page_size=page_size,
            status=status,
            schedule_type=schedule_type,
            content=content,
            request_options=request_options,
        )
        return _response.data


class AsyncSchedulesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSchedulesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSchedulesClient
        """
        return self._raw_client

    async def list(
        self,
        *,
        page_index: typing.Optional[int] = OMIT,
        page_size: typing.Optional[int] = OMIT,
        status: typing.Optional[ListScheduledMessagesRequestStatus] = OMIT,
        schedule_type: typing.Optional[ListScheduledMessagesRequestScheduleType] = OMIT,
        content: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> ListScheduledMessagesResponse:
        """
        List all scheduled messages with optional filtering and pagination. Results are sorted by creation date, newest first.

        Parameters
        ----------
        page_index : typing.Optional[int]

        page_size : typing.Optional[int]

        status : typing.Optional[ListScheduledMessagesRequestStatus]

        schedule_type : typing.Optional[ListScheduledMessagesRequestScheduleType]
            Filter by schedule type — "MESSAGE" for individual messages, "BLAST" for bulk sends.

        content : typing.Optional[str]
            Search scheduled message content (partial match, case-insensitive).

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

        Returns
        -------
        ListScheduledMessagesResponse
            Returns paginated list of scheduled messages.

        Examples
        --------
        import asyncio

        from rcs import AsyncPinnacle

        client = AsyncPinnacle(
            api_key="YOUR_API_KEY",
        )


        async def main() -> None:
            await client.messages.schedules.list()


        asyncio.run(main())
        """
        _response = await self._raw_client.list(
            page_index=page_index,
            page_size=page_size,
            status=status,
            schedule_type=schedule_type,
            content=content,
            request_options=request_options,
        )
        return _response.data
