# 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_app_settings_gamification_config_tiny_object_request_body import (
    DriverAppSettingsGamificationConfigTinyObjectRequestBody,
)
from ..types.driver_app_settings_trailer_selection_config_tiny_object_request_body import (
    DriverAppSettingsTrailerSelectionConfigTinyObjectRequestBody,
)
from ..types.safety_settings_get_safety_settings_response_body import SafetySettingsGetSafetySettingsResponseBody
from ..types.settings_get_compliance_settings_response_body import SettingsGetComplianceSettingsResponseBody
from ..types.settings_get_driver_app_settings_response_body import SettingsGetDriverAppSettingsResponseBody
from ..types.settings_patch_compliance_settings_response_body import SettingsPatchComplianceSettingsResponseBody
from ..types.settings_patch_driver_app_settings_response_body import SettingsPatchDriverAppSettingsResponseBody
from .raw_client import AsyncRawSettingsClient, RawSettingsClient

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


class SettingsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawSettingsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawSettingsClient
        """
        return self._raw_client

    def get_compliance_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SettingsGetComplianceSettingsResponseBody:
        """
        Get organization's compliance settings, including carrier name, office address, and DOT number

         <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 ELD Compliance Settings (US)** under the Compliance 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
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SettingsGetComplianceSettingsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.settings.get_compliance_settings()
        """
        _response = self._raw_client.get_compliance_settings(request_options=request_options)
        return _response.data

    def patch_compliance_settings(
        self,
        *,
        allow_unregulated_vehicles_enabled: typing.Optional[bool] = OMIT,
        canada_hos_enabled: typing.Optional[bool] = OMIT,
        carrier_name: typing.Optional[str] = OMIT,
        dot_number: typing.Optional[int] = OMIT,
        driver_auto_duty_enabled: typing.Optional[bool] = OMIT,
        edit_certified_logs_enabled: typing.Optional[bool] = OMIT,
        force_manual_location_for_duty_status_changes_enabled: typing.Optional[bool] = OMIT,
        force_review_unassigned_hos_enabled: typing.Optional[bool] = OMIT,
        main_office_formatted_address: typing.Optional[str] = OMIT,
        persistent_duty_status_enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SettingsPatchComplianceSettingsResponseBody:
        """
        Update organization's compliance settings, including carrier name, office address, and DOT number

         <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 ELD Compliance Settings (US)** under the Compliance 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
        ----------
        allow_unregulated_vehicles_enabled : typing.Optional[bool]
            [deprecated] Allow Unregulated Vehicles. This setting is deprecated as all organizations can now mark vehicles as unregulated.

        canada_hos_enabled : typing.Optional[bool]
            Enable Canada HOS

        carrier_name : typing.Optional[str]
            Carrier Name / Principal Place of Business Name

        dot_number : typing.Optional[int]
            Carrier US DOT Number

        driver_auto_duty_enabled : typing.Optional[bool]
            Enable Driver Auto-Duty

        edit_certified_logs_enabled : typing.Optional[bool]
            Drivers Can Edit Certified Log

        force_manual_location_for_duty_status_changes_enabled : typing.Optional[bool]
            Force Manual Location For Duty Status Changes

        force_review_unassigned_hos_enabled : typing.Optional[bool]
            Force Review of Unassigned HOS

        main_office_formatted_address : typing.Optional[str]
            Main Office Address / Principal Place of Businesss Address

        persistent_duty_status_enabled : typing.Optional[bool]
            Persistent Duty Status

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

        Returns
        -------
        SettingsPatchComplianceSettingsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.settings.patch_compliance_settings()
        """
        _response = self._raw_client.patch_compliance_settings(
            allow_unregulated_vehicles_enabled=allow_unregulated_vehicles_enabled,
            canada_hos_enabled=canada_hos_enabled,
            carrier_name=carrier_name,
            dot_number=dot_number,
            driver_auto_duty_enabled=driver_auto_duty_enabled,
            edit_certified_logs_enabled=edit_certified_logs_enabled,
            force_manual_location_for_duty_status_changes_enabled=force_manual_location_for_duty_status_changes_enabled,
            force_review_unassigned_hos_enabled=force_review_unassigned_hos_enabled,
            main_office_formatted_address=main_office_formatted_address,
            persistent_duty_status_enabled=persistent_duty_status_enabled,
            request_options=request_options,
        )
        return _response.data

    def get_driver_app_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SettingsGetDriverAppSettingsResponseBody:
        """
        Get driver app settings.

         <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 Driver App Settings** 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
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SettingsGetDriverAppSettingsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.settings.get_driver_app_settings()
        """
        _response = self._raw_client.get_driver_app_settings(request_options=request_options)
        return _response.data

    def patch_driver_app_settings(
        self,
        *,
        driver_fleet_id: typing.Optional[str] = OMIT,
        gamification: typing.Optional[bool] = OMIT,
        gamification_config: typing.Optional[DriverAppSettingsGamificationConfigTinyObjectRequestBody] = OMIT,
        org_vehicle_search: typing.Optional[bool] = OMIT,
        trailer_selection: typing.Optional[bool] = OMIT,
        trailer_selection_config: typing.Optional[DriverAppSettingsTrailerSelectionConfigTinyObjectRequestBody] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SettingsPatchDriverAppSettingsResponseBody:
        """
        Update driver app settings.

         <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 Driver App Settings** 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_fleet_id : typing.Optional[str]
            Global login user name for the fleet driver app

        gamification : typing.Optional[bool]
            Driver gamification feature. Enabling this will turn on the feature for all drivers using the mobile app. Drivers can be configured into peer groups within the Drivers Page. Unconfigured drivers will be grouped on an organization level.

        gamification_config : typing.Optional[DriverAppSettingsGamificationConfigTinyObjectRequestBody]

        org_vehicle_search : typing.Optional[bool]
            Allow drivers to search for vehicles outside of their selection tag when connected to the internet.

        trailer_selection : typing.Optional[bool]
            Allow drivers to see and select trailers in the Samsara Driver app.

        trailer_selection_config : typing.Optional[DriverAppSettingsTrailerSelectionConfigTinyObjectRequestBody]

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

        Returns
        -------
        SettingsPatchDriverAppSettingsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.settings.patch_driver_app_settings()
        """
        _response = self._raw_client.patch_driver_app_settings(
            driver_fleet_id=driver_fleet_id,
            gamification=gamification,
            gamification_config=gamification_config,
            org_vehicle_search=org_vehicle_search,
            trailer_selection=trailer_selection,
            trailer_selection_config=trailer_selection_config,
            request_options=request_options,
        )
        return _response.data

    def get_safety_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SafetySettingsGetSafetySettingsResponseBody:
        """
        Get safety settings

         <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 Safety Events & Scores** under the Safety & Cameras 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
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SafetySettingsGetSafetySettingsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.settings.get_safety_settings()
        """
        _response = self._raw_client.get_safety_settings(request_options=request_options)
        return _response.data


class AsyncSettingsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawSettingsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawSettingsClient
        """
        return self._raw_client

    async def get_compliance_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SettingsGetComplianceSettingsResponseBody:
        """
        Get organization's compliance settings, including carrier name, office address, and DOT number

         <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 ELD Compliance Settings (US)** under the Compliance 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
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SettingsGetComplianceSettingsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.settings.get_compliance_settings()


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

    async def patch_compliance_settings(
        self,
        *,
        allow_unregulated_vehicles_enabled: typing.Optional[bool] = OMIT,
        canada_hos_enabled: typing.Optional[bool] = OMIT,
        carrier_name: typing.Optional[str] = OMIT,
        dot_number: typing.Optional[int] = OMIT,
        driver_auto_duty_enabled: typing.Optional[bool] = OMIT,
        edit_certified_logs_enabled: typing.Optional[bool] = OMIT,
        force_manual_location_for_duty_status_changes_enabled: typing.Optional[bool] = OMIT,
        force_review_unassigned_hos_enabled: typing.Optional[bool] = OMIT,
        main_office_formatted_address: typing.Optional[str] = OMIT,
        persistent_duty_status_enabled: typing.Optional[bool] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SettingsPatchComplianceSettingsResponseBody:
        """
        Update organization's compliance settings, including carrier name, office address, and DOT number

         <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 ELD Compliance Settings (US)** under the Compliance 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
        ----------
        allow_unregulated_vehicles_enabled : typing.Optional[bool]
            [deprecated] Allow Unregulated Vehicles. This setting is deprecated as all organizations can now mark vehicles as unregulated.

        canada_hos_enabled : typing.Optional[bool]
            Enable Canada HOS

        carrier_name : typing.Optional[str]
            Carrier Name / Principal Place of Business Name

        dot_number : typing.Optional[int]
            Carrier US DOT Number

        driver_auto_duty_enabled : typing.Optional[bool]
            Enable Driver Auto-Duty

        edit_certified_logs_enabled : typing.Optional[bool]
            Drivers Can Edit Certified Log

        force_manual_location_for_duty_status_changes_enabled : typing.Optional[bool]
            Force Manual Location For Duty Status Changes

        force_review_unassigned_hos_enabled : typing.Optional[bool]
            Force Review of Unassigned HOS

        main_office_formatted_address : typing.Optional[str]
            Main Office Address / Principal Place of Businesss Address

        persistent_duty_status_enabled : typing.Optional[bool]
            Persistent Duty Status

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

        Returns
        -------
        SettingsPatchComplianceSettingsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.settings.patch_compliance_settings()


        asyncio.run(main())
        """
        _response = await self._raw_client.patch_compliance_settings(
            allow_unregulated_vehicles_enabled=allow_unregulated_vehicles_enabled,
            canada_hos_enabled=canada_hos_enabled,
            carrier_name=carrier_name,
            dot_number=dot_number,
            driver_auto_duty_enabled=driver_auto_duty_enabled,
            edit_certified_logs_enabled=edit_certified_logs_enabled,
            force_manual_location_for_duty_status_changes_enabled=force_manual_location_for_duty_status_changes_enabled,
            force_review_unassigned_hos_enabled=force_review_unassigned_hos_enabled,
            main_office_formatted_address=main_office_formatted_address,
            persistent_duty_status_enabled=persistent_duty_status_enabled,
            request_options=request_options,
        )
        return _response.data

    async def get_driver_app_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SettingsGetDriverAppSettingsResponseBody:
        """
        Get driver app settings.

         <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 Driver App Settings** 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
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SettingsGetDriverAppSettingsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.settings.get_driver_app_settings()


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

    async def patch_driver_app_settings(
        self,
        *,
        driver_fleet_id: typing.Optional[str] = OMIT,
        gamification: typing.Optional[bool] = OMIT,
        gamification_config: typing.Optional[DriverAppSettingsGamificationConfigTinyObjectRequestBody] = OMIT,
        org_vehicle_search: typing.Optional[bool] = OMIT,
        trailer_selection: typing.Optional[bool] = OMIT,
        trailer_selection_config: typing.Optional[DriverAppSettingsTrailerSelectionConfigTinyObjectRequestBody] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> SettingsPatchDriverAppSettingsResponseBody:
        """
        Update driver app settings.

         <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 Driver App Settings** 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_fleet_id : typing.Optional[str]
            Global login user name for the fleet driver app

        gamification : typing.Optional[bool]
            Driver gamification feature. Enabling this will turn on the feature for all drivers using the mobile app. Drivers can be configured into peer groups within the Drivers Page. Unconfigured drivers will be grouped on an organization level.

        gamification_config : typing.Optional[DriverAppSettingsGamificationConfigTinyObjectRequestBody]

        org_vehicle_search : typing.Optional[bool]
            Allow drivers to search for vehicles outside of their selection tag when connected to the internet.

        trailer_selection : typing.Optional[bool]
            Allow drivers to see and select trailers in the Samsara Driver app.

        trailer_selection_config : typing.Optional[DriverAppSettingsTrailerSelectionConfigTinyObjectRequestBody]

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

        Returns
        -------
        SettingsPatchDriverAppSettingsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.settings.patch_driver_app_settings()


        asyncio.run(main())
        """
        _response = await self._raw_client.patch_driver_app_settings(
            driver_fleet_id=driver_fleet_id,
            gamification=gamification,
            gamification_config=gamification_config,
            org_vehicle_search=org_vehicle_search,
            trailer_selection=trailer_selection,
            trailer_selection_config=trailer_selection_config,
            request_options=request_options,
        )
        return _response.data

    async def get_safety_settings(
        self, *, request_options: typing.Optional[RequestOptions] = None
    ) -> SafetySettingsGetSafetySettingsResponseBody:
        """
        Get safety settings

         <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 Safety Events & Scores** under the Safety & Cameras 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
        ----------
        request_options : typing.Optional[RequestOptions]
            Request-specific configuration.

        Returns
        -------
        SafetySettingsGetSafetySettingsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.settings.get_safety_settings()


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