# 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.driver_qr_codes_create_driver_qr_code_response_body import DriverQrCodesCreateDriverQrCodeResponseBody
from ..types.driver_qr_codes_get_drivers_qr_codes_response_body import DriverQrCodesGetDriversQrCodesResponseBody
from .raw_client import AsyncRawDriverQrCodesClient, RawDriverQrCodesClient

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


class DriverQrCodesClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawDriverQrCodesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawDriverQrCodesClient
        """
        return self._raw_client

    def get_drivers_qr_codes(
        self,
        *,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DriverQrCodesGetDriversQrCodesResponseBody:
        """
        Get details for requested driver(s) QR code, used for driver trip assignment.

         <b>Rate limit:</b> 5 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

        To use this endpoint, select **Read Drivers** under the Drivers category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>


         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        Parameters
        ----------
        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            String of comma separated driver IDs. List of driver - QR codes for specified driver(s) will be returned.

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

        Returns
        -------
        DriverQrCodesGetDriversQrCodesResponseBody
            OK response.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.driver_qr_codes.get_drivers_qr_codes()
        """
        _response = self._raw_client.get_drivers_qr_codes(driver_ids=driver_ids, request_options=request_options)
        return _response.data

    def create_driver_qr_code(
        self, *, driver_id: int, request_options: typing.Optional[RequestOptions] = None
    ) -> DriverQrCodesCreateDriverQrCodeResponseBody:
        """
        Assign a new QR code for the requested driver. Return error if an active QR code already exists.

         <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

        To use this endpoint, select **Write Drivers** under the Drivers category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>


         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        Parameters
        ----------
        driver_id : int
            Unique ID of the driver.

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

        Returns
        -------
        DriverQrCodesCreateDriverQrCodeResponseBody
            OK response.

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.driver_qr_codes.create_driver_qr_code(
            driver_id=494123,
        )
        """
        _response = self._raw_client.create_driver_qr_code(driver_id=driver_id, request_options=request_options)
        return _response.data

    def delete_driver_qr_code(self, *, driver_id: int, request_options: typing.Optional[RequestOptions] = None) -> None:
        """
        Revoke requested driver's currently active QR code.

         <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

        To use this endpoint, select **Write Drivers** under the Drivers category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>


         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        Parameters
        ----------
        driver_id : int
            Unique ID of the driver.

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

        Returns
        -------
        None

        Examples
        --------
        from samsara import Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.driver_qr_codes.delete_driver_qr_code(
            driver_id=494123,
        )
        """
        _response = self._raw_client.delete_driver_qr_code(driver_id=driver_id, request_options=request_options)
        return _response.data


class AsyncDriverQrCodesClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawDriverQrCodesClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawDriverQrCodesClient
        """
        return self._raw_client

    async def get_drivers_qr_codes(
        self,
        *,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DriverQrCodesGetDriversQrCodesResponseBody:
        """
        Get details for requested driver(s) QR code, used for driver trip assignment.

         <b>Rate limit:</b> 5 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

        To use this endpoint, select **Read Drivers** under the Drivers category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>


         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        Parameters
        ----------
        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            String of comma separated driver IDs. List of driver - QR codes for specified driver(s) will be returned.

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

        Returns
        -------
        DriverQrCodesGetDriversQrCodesResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.driver_qr_codes.get_drivers_qr_codes()


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

    async def create_driver_qr_code(
        self, *, driver_id: int, request_options: typing.Optional[RequestOptions] = None
    ) -> DriverQrCodesCreateDriverQrCodeResponseBody:
        """
        Assign a new QR code for the requested driver. Return error if an active QR code already exists.

         <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

        To use this endpoint, select **Write Drivers** under the Drivers category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>


         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        Parameters
        ----------
        driver_id : int
            Unique ID of the driver.

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

        Returns
        -------
        DriverQrCodesCreateDriverQrCodeResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.driver_qr_codes.create_driver_qr_code(
                driver_id=494123,
            )


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

    async def delete_driver_qr_code(
        self, *, driver_id: int, request_options: typing.Optional[RequestOptions] = None
    ) -> None:
        """
        Revoke requested driver's currently active QR code.

         <b>Rate limit:</b> 100 requests/min (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).

        To use this endpoint, select **Write Drivers** under the Drivers category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>


         **Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.

        Parameters
        ----------
        driver_id : int
            Unique ID of the driver.

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

        Returns
        -------
        None

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.driver_qr_codes.delete_driver_qr_code(
                driver_id=494123,
            )


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