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

import datetime as dt
import typing

from .....core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
from .....core.request_options import RequestOptions
from ....commons.types.page_token import PageToken
from .raw_client import AsyncRawV1Client, RawV1Client
from .types.event import Event
from .types.event_id import EventId
from .types.event_scan_page import EventScanPage


class V1Client:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawV1Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawV1Client
        """
        return self._raw_client

    def scan(
        self,
        *,
        page_token: typing.Optional[PageToken] = None,
        limit: typing.Optional[int] = None,
        event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        created_before: typing.Optional[dt.datetime] = None,
        created_after: typing.Optional[dt.datetime] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EventScanPage:
        """
        Scans the last 30 days of events. All results are sorted by created date, descending.

        Parameters
        ----------
        page_token : typing.Optional[PageToken]

        limit : typing.Optional[int]
            Number of events to return. Minimum value is 1, maximum is 100. Defaults to 10.

        event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Event types to filter on. Defaults to showing all event types.

            | Event Type | Description |
            |------------|-------------|
            | `CandidApi.Encounter.Created` | When a new claim is created |
            | `CandidApi.Encounter.StatusUpdated` | When a claim's status has been updated |
            | `PreEncounter.Patient.Created` | When a new patient has been created |
            | `PreEncounter.Patient.Updated` | When a patient's information has been updated |
            | `PreEncounter.Coverage.Created` | When a new coverage has been created for a patient |
            | `PreEncounter.Coverage.Updated` | When a patient's coverage has been updated |
            | `PreEncounter.Tag.Created` | When a new tag has been created for a patient |
            | `PreEncounter.Tag.Updated` | When a patient's tag has been updated |

        created_before : typing.Optional[dt.datetime]
            Filters for only events created before this time (inclusive).

        created_after : typing.Optional[dt.datetime]
            Filters for only events created after this time (inclusive).

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

        Returns
        -------
        EventScanPage

        Examples
        --------
        from candid import CandidApiClient

        client = CandidApiClient(
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.events.v_1.scan()
        """
        _response = self._raw_client.scan(
            page_token=page_token,
            limit=limit,
            event_types=event_types,
            created_before=created_before,
            created_after=created_after,
            request_options=request_options,
        )
        return _response.data

    def get(self, event_id: EventId, *, request_options: typing.Optional[RequestOptions] = None) -> Event:
        """
        Parameters
        ----------
        event_id : EventId

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

        Returns
        -------
        Event

        Examples
        --------
        import uuid

        from candid import CandidApiClient

        client = CandidApiClient(
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )
        client.events.v_1.get(
            event_id=uuid.UUID(
                "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
            ),
        )
        """
        _response = self._raw_client.get(event_id, request_options=request_options)
        return _response.data


class AsyncV1Client:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawV1Client(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawV1Client
        """
        return self._raw_client

    async def scan(
        self,
        *,
        page_token: typing.Optional[PageToken] = None,
        limit: typing.Optional[int] = None,
        event_types: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        created_before: typing.Optional[dt.datetime] = None,
        created_after: typing.Optional[dt.datetime] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> EventScanPage:
        """
        Scans the last 30 days of events. All results are sorted by created date, descending.

        Parameters
        ----------
        page_token : typing.Optional[PageToken]

        limit : typing.Optional[int]
            Number of events to return. Minimum value is 1, maximum is 100. Defaults to 10.

        event_types : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            Event types to filter on. Defaults to showing all event types.

            | Event Type | Description |
            |------------|-------------|
            | `CandidApi.Encounter.Created` | When a new claim is created |
            | `CandidApi.Encounter.StatusUpdated` | When a claim's status has been updated |
            | `PreEncounter.Patient.Created` | When a new patient has been created |
            | `PreEncounter.Patient.Updated` | When a patient's information has been updated |
            | `PreEncounter.Coverage.Created` | When a new coverage has been created for a patient |
            | `PreEncounter.Coverage.Updated` | When a patient's coverage has been updated |
            | `PreEncounter.Tag.Created` | When a new tag has been created for a patient |
            | `PreEncounter.Tag.Updated` | When a patient's tag has been updated |

        created_before : typing.Optional[dt.datetime]
            Filters for only events created before this time (inclusive).

        created_after : typing.Optional[dt.datetime]
            Filters for only events created after this time (inclusive).

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

        Returns
        -------
        EventScanPage

        Examples
        --------
        import asyncio

        from candid import AsyncCandidApiClient

        client = AsyncCandidApiClient(
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.events.v_1.scan()


        asyncio.run(main())
        """
        _response = await self._raw_client.scan(
            page_token=page_token,
            limit=limit,
            event_types=event_types,
            created_before=created_before,
            created_after=created_after,
            request_options=request_options,
        )
        return _response.data

    async def get(self, event_id: EventId, *, request_options: typing.Optional[RequestOptions] = None) -> Event:
        """
        Parameters
        ----------
        event_id : EventId

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

        Returns
        -------
        Event

        Examples
        --------
        import asyncio
        import uuid

        from candid import AsyncCandidApiClient

        client = AsyncCandidApiClient(
            client_id="YOUR_CLIENT_ID",
            client_secret="YOUR_CLIENT_SECRET",
        )


        async def main() -> None:
            await client.events.v_1.get(
                event_id=uuid.UUID(
                    "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
                ),
            )


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