# 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_efficiency_get_driver_efficiency_by_drivers_response_body import (
    DriverEfficiencyGetDriverEfficiencyByDriversResponseBody,
)
from ..types.driver_efficiency_get_driver_efficiency_by_vehicles_response_body import (
    DriverEfficiencyGetDriverEfficiencyByVehiclesResponseBody,
)
from ..types.fuel_energy_get_fuel_energy_driver_reports_response_body import (
    FuelEnergyGetFuelEnergyDriverReportsResponseBody,
)
from ..types.fuel_energy_get_fuel_energy_vehicle_reports_response_body import (
    FuelEnergyGetFuelEnergyVehicleReportsResponseBody,
)
from ..types.fuel_purchase_post_fuel_purchase_response_body import FuelPurchasePostFuelPurchaseResponseBody
from ..types.post_fuel_purchase_request_body_discount_request_body import PostFuelPurchaseRequestBodyDiscountRequestBody
from ..types.post_fuel_purchase_request_body_price_request_body import PostFuelPurchaseRequestBodyPriceRequestBody
from .raw_client import AsyncRawFuelAndEnergyClient, RawFuelAndEnergyClient
from .types.fuel_purchase_post_fuel_purchase_request_body_fuel_grade import (
    FuelPurchasePostFuelPurchaseRequestBodyFuelGrade,
)
from .types.fuel_purchase_post_fuel_purchase_request_body_ifta_fuel_type import (
    FuelPurchasePostFuelPurchaseRequestBodyIftaFuelType,
)
from .types.get_fuel_energy_vehicle_reports_request_energy_type import GetFuelEnergyVehicleReportsRequestEnergyType

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


class FuelAndEnergyClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawFuelAndEnergyClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawFuelAndEnergyClient
        """
        return self._raw_client

    def get_driver_efficiency_by_drivers(
        self,
        *,
        start_time: str,
        end_time: str,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        data_formats: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DriverEfficiencyGetDriverEfficiencyByDriversResponseBody:
        """
        This endpoint will return driver efficiency data that has been collected for your organization and grouped by drivers based on the time parameters passed in. Results are paginated.

        **Note:** The data from this endpoint comes from the Driver Efficiency (Eco-Driving) Report. The existing [/fleet/drivers/efficiency](https://developers.samsara.com/reference/getdriverefficiency) endpoint has now been moved to Legacy.

         <b>Rate limit:</b> 10 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 Efficiency** under the Fuel & Energy 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
        ----------
        start_time : str
            A start time in RFC 3339 format. Must be in multiple of hours and at least 1 day before endTime. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-11T19:00:00Z, 2015-09-12T14:00:00-04:00).

        end_time : str
            An end time in RFC 3339 format. Must be in multiple of hours and no later than 3 hours before the current time. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-13T19:00:00Z, 2015-09-15T14:00:00-04:00).

        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
             A filter on the data based on this comma-separated list of driver IDs and externalIds. Example: `driverIds=1234,5678,payroll:4841`

        data_formats : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of data formats you want to fetch. Valid values: `score`, `raw` and `percentage`. The default data format is `score`. Example: `dataFormats=raw,score`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        DriverEfficiencyGetDriverEfficiencyByDriversResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.fuel_and_energy.get_driver_efficiency_by_drivers(
            start_time="startTime",
            end_time="endTime",
        )
        """
        _response = self._raw_client.get_driver_efficiency_by_drivers(
            start_time=start_time,
            end_time=end_time,
            driver_ids=driver_ids,
            data_formats=data_formats,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    def get_driver_efficiency_by_vehicles(
        self,
        *,
        start_time: str,
        end_time: str,
        vehicle_ids: typing.Optional[str] = None,
        data_formats: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DriverEfficiencyGetDriverEfficiencyByVehiclesResponseBody:
        """
        This endpoint will return driver efficiency data that has been collected for your organization and grouped by vehicle drivers used based on the time parameters passed in. Results are paginated.

        **Note:** The data from this endpoint comes from the Driver Efficiency (Eco-Driving) Report. The existing [/fleet/drivers/efficiency](https://developers.samsara.com/reference/getdriverefficiency) endpoint has now been moved to Legacy.

         <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 Efficiency** under the Fuel & Energy 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
        ----------
        start_time : str
            A start time in RFC 3339 format. Must be in multiple of hours and at least 1 day before endTime. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-11T19:00:00Z, 2015-09-12T14:00:00-04:00).

        end_time : str
            An end time in RFC 3339 format. Must be in multiple of hours and no later than 3 hours before the current time. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-13T19:00:00Z, 2015-09-15T14:00:00-04:00).

        vehicle_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of vehicle IDs and externalIds. Example: `vehicleIds=1234,5678,samsara.vin:1HGBH41JXMN109186`

        data_formats : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of data formats you want to fetch. Valid values: `score`, `raw` and `percentage`. The default data format is `score`. Example: `dataFormats=raw,score`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        DriverEfficiencyGetDriverEfficiencyByVehiclesResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.fuel_and_energy.get_driver_efficiency_by_vehicles(
            start_time="startTime",
            end_time="endTime",
        )
        """
        _response = self._raw_client.get_driver_efficiency_by_vehicles(
            start_time=start_time,
            end_time=end_time,
            vehicle_ids=vehicle_ids,
            data_formats=data_formats,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    def get_fuel_energy_driver_reports(
        self,
        *,
        start_date: str,
        end_date: str,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FuelEnergyGetFuelEnergyDriverReportsResponseBody:
        """
        Get fuel and energy efficiency driver reports for the requested time range.

         <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 Fuel & Energy** under the Fuel & Energy 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
        ----------
        start_date : str
            A start date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        end_date : str
            An end date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
             A filter on the data based on this comma-separated list of driver IDs and externalIds. Example: `driverIds=1234,5678,payroll:4841`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        FuelEnergyGetFuelEnergyDriverReportsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.fuel_and_energy.get_fuel_energy_driver_reports(
            start_date="startDate",
            end_date="endDate",
        )
        """
        _response = self._raw_client.get_fuel_energy_driver_reports(
            start_date=start_date,
            end_date=end_date,
            driver_ids=driver_ids,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    def get_fuel_energy_vehicle_reports(
        self,
        *,
        start_date: str,
        end_date: str,
        vehicle_ids: typing.Optional[str] = None,
        energy_type: typing.Optional[GetFuelEnergyVehicleReportsRequestEnergyType] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FuelEnergyGetFuelEnergyVehicleReportsResponseBody:
        """
        Get fuel and energy efficiency vehicle reports for the requested time range.

         <b>Rate limit:</b> 25 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 Fuel & Energy** under the Fuel & Energy 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
        ----------
        start_date : str
            A start date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        end_date : str
            An end date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        vehicle_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of vehicle IDs and externalIds. Example: `vehicleIds=1234,5678,samsara.vin:1HGBH41JXMN109186`

        energy_type : typing.Optional[GetFuelEnergyVehicleReportsRequestEnergyType]
            The type of energy used by the vehicle.  Valid values: `fuel`, `hybrid`, `electric`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        FuelEnergyGetFuelEnergyVehicleReportsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.fuel_and_energy.get_fuel_energy_vehicle_reports(
            start_date="startDate",
            end_date="endDate",
        )
        """
        _response = self._raw_client.get_fuel_energy_vehicle_reports(
            start_date=start_date,
            end_date=end_date,
            vehicle_ids=vehicle_ids,
            energy_type=energy_type,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    def post_fuel_purchase(
        self,
        *,
        fuel_quantity_liters: str,
        transaction_location: str,
        transaction_price: PostFuelPurchaseRequestBodyPriceRequestBody,
        transaction_reference: str,
        transaction_time: str,
        discount: typing.Optional[PostFuelPurchaseRequestBodyDiscountRequestBody] = OMIT,
        driver_id: typing.Optional[str] = OMIT,
        fuel_grade: typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyFuelGrade] = OMIT,
        ifta_fuel_type: typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyIftaFuelType] = OMIT,
        merchant_name: typing.Optional[str] = OMIT,
        source: typing.Optional[str] = OMIT,
        vehicle_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FuelPurchasePostFuelPurchaseResponseBody:
        """
        Create a fuel purchase transaction.

         <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 Fuel Purchase** under the Fuel & Energy 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
        ----------
        fuel_quantity_liters : str
            The amount of fuel purchased in liters.

        transaction_location : str
            The full street address for the location of the fuel transaction, as it might be recognized by Google Maps. Ideal entries should be in accordance with the format used by the national postal service of the country concerned (example: 1 De Haro St, San Francisco, CA 94107, United States). Alternatively, exact latitude/longitude can be provided (example: 40.748441, -73.985664).

        transaction_price : PostFuelPurchaseRequestBodyPriceRequestBody

        transaction_reference : str
            The fuel transaction reference. This is the transaction identifier. For instance, this can be the Serial Number on the invoice.

        transaction_time : str
            The time of the fuel transaction in RFC 3339 format. Timezone must be specified. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        discount : typing.Optional[PostFuelPurchaseRequestBodyDiscountRequestBody]

        driver_id : typing.Optional[str]
            Samsara ID of the driver that purchased the fuel.

        fuel_grade : typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyFuelGrade]
            The grade of the fuel purchased.  Valid values: `Unknown`, `Regular`, `Premium`

        ifta_fuel_type : typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyIftaFuelType]
            The type of fuel purchased supported by IFTA.  Valid values: `Unspecified`, `A55`, `Biodiesel`, `CompressedNaturalGas`, `Diesel`, `E85`, `Electricity`, `Ethanol`, `Gasohol`, `Gasoline`, `Hydrogen`, `LiquifiedNaturalGas`, `M85`, `Methanol`, `Propane`, `Other`

        merchant_name : typing.Optional[str]
            Brand name of the fuel station the fuel was purchased at. For example: Shell, Bp, Exxon.

        source : typing.Optional[str]
            The integration provider. For example: Customer, Shell Integration

        vehicle_id : typing.Optional[str]
            Samsara ID of the vehicle that purchased the fuel.

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

        Returns
        -------
        FuelPurchasePostFuelPurchaseResponseBody
            OK response.

        Examples
        --------
        from samsara import PostFuelPurchaseRequestBodyPriceRequestBody, Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.fuel_and_energy.post_fuel_purchase(
            fuel_quantity_liters="676.8",
            transaction_location="350 Rhode Island St, San Francisco, CA 94103",
            transaction_price=PostFuelPurchaseRequestBodyPriceRequestBody(
                amount="640.2",
                currency="usd",
            ),
            transaction_reference="5454534",
            transaction_time="2022-07-13T14:20:50.52-07:00",
        )
        """
        _response = self._raw_client.post_fuel_purchase(
            fuel_quantity_liters=fuel_quantity_liters,
            transaction_location=transaction_location,
            transaction_price=transaction_price,
            transaction_reference=transaction_reference,
            transaction_time=transaction_time,
            discount=discount,
            driver_id=driver_id,
            fuel_grade=fuel_grade,
            ifta_fuel_type=ifta_fuel_type,
            merchant_name=merchant_name,
            source=source,
            vehicle_id=vehicle_id,
            request_options=request_options,
        )
        return _response.data


class AsyncFuelAndEnergyClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawFuelAndEnergyClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawFuelAndEnergyClient
        """
        return self._raw_client

    async def get_driver_efficiency_by_drivers(
        self,
        *,
        start_time: str,
        end_time: str,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        data_formats: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DriverEfficiencyGetDriverEfficiencyByDriversResponseBody:
        """
        This endpoint will return driver efficiency data that has been collected for your organization and grouped by drivers based on the time parameters passed in. Results are paginated.

        **Note:** The data from this endpoint comes from the Driver Efficiency (Eco-Driving) Report. The existing [/fleet/drivers/efficiency](https://developers.samsara.com/reference/getdriverefficiency) endpoint has now been moved to Legacy.

         <b>Rate limit:</b> 10 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 Efficiency** under the Fuel & Energy 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
        ----------
        start_time : str
            A start time in RFC 3339 format. Must be in multiple of hours and at least 1 day before endTime. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-11T19:00:00Z, 2015-09-12T14:00:00-04:00).

        end_time : str
            An end time in RFC 3339 format. Must be in multiple of hours and no later than 3 hours before the current time. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-13T19:00:00Z, 2015-09-15T14:00:00-04:00).

        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
             A filter on the data based on this comma-separated list of driver IDs and externalIds. Example: `driverIds=1234,5678,payroll:4841`

        data_formats : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of data formats you want to fetch. Valid values: `score`, `raw` and `percentage`. The default data format is `score`. Example: `dataFormats=raw,score`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        DriverEfficiencyGetDriverEfficiencyByDriversResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.fuel_and_energy.get_driver_efficiency_by_drivers(
                start_time="startTime",
                end_time="endTime",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_driver_efficiency_by_drivers(
            start_time=start_time,
            end_time=end_time,
            driver_ids=driver_ids,
            data_formats=data_formats,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    async def get_driver_efficiency_by_vehicles(
        self,
        *,
        start_time: str,
        end_time: str,
        vehicle_ids: typing.Optional[str] = None,
        data_formats: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> DriverEfficiencyGetDriverEfficiencyByVehiclesResponseBody:
        """
        This endpoint will return driver efficiency data that has been collected for your organization and grouped by vehicle drivers used based on the time parameters passed in. Results are paginated.

        **Note:** The data from this endpoint comes from the Driver Efficiency (Eco-Driving) Report. The existing [/fleet/drivers/efficiency](https://developers.samsara.com/reference/getdriverefficiency) endpoint has now been moved to Legacy.

         <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 Efficiency** under the Fuel & Energy 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
        ----------
        start_time : str
            A start time in RFC 3339 format. Must be in multiple of hours and at least 1 day before endTime. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-11T19:00:00Z, 2015-09-12T14:00:00-04:00).

        end_time : str
            An end time in RFC 3339 format. Must be in multiple of hours and no later than 3 hours before the current time. Timezones are supported. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. (Examples: 2019-06-13T19:00:00Z, 2015-09-15T14:00:00-04:00).

        vehicle_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of vehicle IDs and externalIds. Example: `vehicleIds=1234,5678,samsara.vin:1HGBH41JXMN109186`

        data_formats : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of data formats you want to fetch. Valid values: `score`, `raw` and `percentage`. The default data format is `score`. Example: `dataFormats=raw,score`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        DriverEfficiencyGetDriverEfficiencyByVehiclesResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.fuel_and_energy.get_driver_efficiency_by_vehicles(
                start_time="startTime",
                end_time="endTime",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_driver_efficiency_by_vehicles(
            start_time=start_time,
            end_time=end_time,
            vehicle_ids=vehicle_ids,
            data_formats=data_formats,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    async def get_fuel_energy_driver_reports(
        self,
        *,
        start_date: str,
        end_date: str,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FuelEnergyGetFuelEnergyDriverReportsResponseBody:
        """
        Get fuel and energy efficiency driver reports for the requested time range.

         <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 Fuel & Energy** under the Fuel & Energy 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
        ----------
        start_date : str
            A start date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        end_date : str
            An end date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
             A filter on the data based on this comma-separated list of driver IDs and externalIds. Example: `driverIds=1234,5678,payroll:4841`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        FuelEnergyGetFuelEnergyDriverReportsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.fuel_and_energy.get_fuel_energy_driver_reports(
                start_date="startDate",
                end_date="endDate",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_fuel_energy_driver_reports(
            start_date=start_date,
            end_date=end_date,
            driver_ids=driver_ids,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    async def get_fuel_energy_vehicle_reports(
        self,
        *,
        start_date: str,
        end_date: str,
        vehicle_ids: typing.Optional[str] = None,
        energy_type: typing.Optional[GetFuelEnergyVehicleReportsRequestEnergyType] = None,
        tag_ids: typing.Optional[str] = None,
        parent_tag_ids: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FuelEnergyGetFuelEnergyVehicleReportsResponseBody:
        """
        Get fuel and energy efficiency vehicle reports for the requested time range.

         <b>Rate limit:</b> 25 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 Fuel & Energy** under the Fuel & Energy 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
        ----------
        start_date : str
            A start date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        end_date : str
            An end date in RFC 3339 format. This parameter ignores everything (i.e. hour, minutes, seconds, nanoseconds, etc.) besides the date and timezone. If no time zone is passed in, then the UTC time zone will be used. This parameter is inclusive, so data on the date specified will be considered. Note that the most recent 72 hours of data may still be processing and is subject to change and latency, so it is not recommended to request data for the most recent 72 hours. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        vehicle_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of vehicle IDs and externalIds. Example: `vehicleIds=1234,5678,samsara.vin:1HGBH41JXMN109186`

        energy_type : typing.Optional[GetFuelEnergyVehicleReportsRequestEnergyType]
            The type of energy used by the vehicle.  Valid values: `fuel`, `hybrid`, `electric`

        tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of tag IDs. Example: `tagIds=1234,5678`

        parent_tag_ids : typing.Optional[str]
             A filter on the data based on this comma-separated list of parent tag IDs, for use by orgs with tag hierarchies. Specifying a parent tag will implicitly include all descendent tags of the parent tag. Example: `parentTagIds=345,678`

        after : typing.Optional[str]
             If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.

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

        Returns
        -------
        FuelEnergyGetFuelEnergyVehicleReportsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.fuel_and_energy.get_fuel_energy_vehicle_reports(
                start_date="startDate",
                end_date="endDate",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_fuel_energy_vehicle_reports(
            start_date=start_date,
            end_date=end_date,
            vehicle_ids=vehicle_ids,
            energy_type=energy_type,
            tag_ids=tag_ids,
            parent_tag_ids=parent_tag_ids,
            after=after,
            request_options=request_options,
        )
        return _response.data

    async def post_fuel_purchase(
        self,
        *,
        fuel_quantity_liters: str,
        transaction_location: str,
        transaction_price: PostFuelPurchaseRequestBodyPriceRequestBody,
        transaction_reference: str,
        transaction_time: str,
        discount: typing.Optional[PostFuelPurchaseRequestBodyDiscountRequestBody] = OMIT,
        driver_id: typing.Optional[str] = OMIT,
        fuel_grade: typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyFuelGrade] = OMIT,
        ifta_fuel_type: typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyIftaFuelType] = OMIT,
        merchant_name: typing.Optional[str] = OMIT,
        source: typing.Optional[str] = OMIT,
        vehicle_id: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FuelPurchasePostFuelPurchaseResponseBody:
        """
        Create a fuel purchase transaction.

         <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 Fuel Purchase** under the Fuel & Energy 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
        ----------
        fuel_quantity_liters : str
            The amount of fuel purchased in liters.

        transaction_location : str
            The full street address for the location of the fuel transaction, as it might be recognized by Google Maps. Ideal entries should be in accordance with the format used by the national postal service of the country concerned (example: 1 De Haro St, San Francisco, CA 94107, United States). Alternatively, exact latitude/longitude can be provided (example: 40.748441, -73.985664).

        transaction_price : PostFuelPurchaseRequestBodyPriceRequestBody

        transaction_reference : str
            The fuel transaction reference. This is the transaction identifier. For instance, this can be the Serial Number on the invoice.

        transaction_time : str
            The time of the fuel transaction in RFC 3339 format. Timezone must be specified. For example, 2022-07-13T14:20:50.52-07:00 is a time in Pacific Daylight Time.

        discount : typing.Optional[PostFuelPurchaseRequestBodyDiscountRequestBody]

        driver_id : typing.Optional[str]
            Samsara ID of the driver that purchased the fuel.

        fuel_grade : typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyFuelGrade]
            The grade of the fuel purchased.  Valid values: `Unknown`, `Regular`, `Premium`

        ifta_fuel_type : typing.Optional[FuelPurchasePostFuelPurchaseRequestBodyIftaFuelType]
            The type of fuel purchased supported by IFTA.  Valid values: `Unspecified`, `A55`, `Biodiesel`, `CompressedNaturalGas`, `Diesel`, `E85`, `Electricity`, `Ethanol`, `Gasohol`, `Gasoline`, `Hydrogen`, `LiquifiedNaturalGas`, `M85`, `Methanol`, `Propane`, `Other`

        merchant_name : typing.Optional[str]
            Brand name of the fuel station the fuel was purchased at. For example: Shell, Bp, Exxon.

        source : typing.Optional[str]
            The integration provider. For example: Customer, Shell Integration

        vehicle_id : typing.Optional[str]
            Samsara ID of the vehicle that purchased the fuel.

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

        Returns
        -------
        FuelPurchasePostFuelPurchaseResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara, PostFuelPurchaseRequestBodyPriceRequestBody

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.fuel_and_energy.post_fuel_purchase(
                fuel_quantity_liters="676.8",
                transaction_location="350 Rhode Island St, San Francisco, CA 94103",
                transaction_price=PostFuelPurchaseRequestBodyPriceRequestBody(
                    amount="640.2",
                    currency="usd",
                ),
                transaction_reference="5454534",
                transaction_time="2022-07-13T14:20:50.52-07:00",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_fuel_purchase(
            fuel_quantity_liters=fuel_quantity_liters,
            transaction_location=transaction_location,
            transaction_price=transaction_price,
            transaction_reference=transaction_reference,
            transaction_time=transaction_time,
            discount=discount,
            driver_id=driver_id,
            fuel_grade=fuel_grade,
            ifta_fuel_type=ifta_fuel_type,
            merchant_name=merchant_name,
            source=source,
            vehicle_id=vehicle_id,
            request_options=request_options,
        )
        return _response.data
