# 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 ..types.form_submission_request_approval_details_request_body import (
    FormSubmissionRequestApprovalDetailsRequestBody,
)
from ..types.form_submission_request_assigned_to_request_body import FormSubmissionRequestAssignedToRequestBody
from ..types.form_submission_request_field_input_object_request_body import (
    FormSubmissionRequestFieldInputObjectRequestBody,
)
from ..types.form_submissions_get_form_submissions_pdf_exports_response_body import (
    FormSubmissionsGetFormSubmissionsPdfExportsResponseBody,
)
from ..types.form_submissions_get_form_submissions_response_body import FormSubmissionsGetFormSubmissionsResponseBody
from ..types.form_submissions_get_form_submissions_stream_response_body import (
    FormSubmissionsGetFormSubmissionsStreamResponseBody,
)
from ..types.form_submissions_patch_form_submission_response_body import FormSubmissionsPatchFormSubmissionResponseBody
from ..types.form_submissions_post_form_submission_response_body import FormSubmissionsPostFormSubmissionResponseBody
from ..types.form_submissions_post_form_submissions_pdf_exports_response_body import (
    FormSubmissionsPostFormSubmissionsPdfExportsResponseBody,
)
from ..types.form_template_request_object_request_body import FormTemplateRequestObjectRequestBody
from ..types.form_templates_get_form_templates_response_body import FormTemplatesGetFormTemplatesResponseBody
from .raw_client import AsyncRawFormsClient, RawFormsClient
from .types.form_submissions_patch_form_submission_request_body_status import (
    FormSubmissionsPatchFormSubmissionRequestBodyStatus,
)
from .types.form_submissions_post_form_submission_request_body_status import (
    FormSubmissionsPostFormSubmissionRequestBodyStatus,
)

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


class FormsClient:
    def __init__(self, *, client_wrapper: SyncClientWrapper):
        self._raw_client = RawFormsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        RawFormsClient
        """
        return self._raw_client

    def get_form_submissions(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsGetFormSubmissionsResponseBody:
        """
        Returns all form submissions data for the specified list of IDs.

         <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 Form Submissions** under the Forms 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
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 100 form submission IDs to filter on. Can be either a unique Samsara ID or an [external ID](https://developers.samsara.com/docs/external-ids) for the form submission.

        include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of strings indicating whether to return additional information. Valid values: `externalIds`

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

        Returns
        -------
        FormSubmissionsGetFormSubmissionsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.get_form_submissions()
        """
        _response = self._raw_client.get_form_submissions(ids=ids, include=include, request_options=request_options)
        return _response.data

    def post_form_submission(
        self,
        *,
        form_template: FormTemplateRequestObjectRequestBody,
        status: FormSubmissionsPostFormSubmissionRequestBodyStatus,
        assigned_to: typing.Optional[FormSubmissionRequestAssignedToRequestBody] = OMIT,
        due_at_time: typing.Optional[dt.datetime] = OMIT,
        fields: typing.Optional[typing.Sequence[FormSubmissionRequestFieldInputObjectRequestBody]] = OMIT,
        is_required: typing.Optional[bool] = OMIT,
        route_stop_id: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsPostFormSubmissionResponseBody:
        """
        Creates a form submission and assigns it to an individual worker. This endpoint can be used to create an empty or partially complete form submission and assign it to a worker.

         <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 Form Submissions** under the Forms 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
        ----------
        form_template : FormTemplateRequestObjectRequestBody

        status : FormSubmissionsPostFormSubmissionRequestBodyStatus
            Status of the form submission.  Valid values: `notStarted`

        assigned_to : typing.Optional[FormSubmissionRequestAssignedToRequestBody]

        due_at_time : typing.Optional[dt.datetime]
            Due date of the form submission. UTC timestamp in RFC 3339 format.

        fields : typing.Optional[typing.Sequence[FormSubmissionRequestFieldInputObjectRequestBody]]
            List of field inputs in a form submission.

        is_required : typing.Optional[bool]
            Indicates whether the worker is required to complete this form or not at a specific route stop. Defaults to `true` if the form is assigned to a user or driver. When true, the worker cannot depart the route stop until this form submission is `submitted`.

        route_stop_id : typing.Optional[str]
            ID of the route stop the form submission is assigned to. Must be a unique Samsara ID.

        title : typing.Optional[str]
            Title of the form submission.

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

        Returns
        -------
        FormSubmissionsPostFormSubmissionResponseBody
            OK response.

        Examples
        --------
        from samsara import FormTemplateRequestObjectRequestBody, Samsara

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.post_form_submission(
            form_template=FormTemplateRequestObjectRequestBody(
                id="9814a1fa-f0c6-408b-bf85-51dc3bc71ac7",
                revision_id="1214a1fa-f0c6-408b-bf85-51dc3bc71ac7",
            ),
            status="notStarted",
        )
        """
        _response = self._raw_client.post_form_submission(
            form_template=form_template,
            status=status,
            assigned_to=assigned_to,
            due_at_time=due_at_time,
            fields=fields,
            is_required=is_required,
            route_stop_id=route_stop_id,
            title=title,
            request_options=request_options,
        )
        return _response.data

    def patch_form_submission(
        self,
        *,
        id: str,
        approval_details: typing.Optional[FormSubmissionRequestApprovalDetailsRequestBody] = OMIT,
        assigned_to: typing.Optional[FormSubmissionRequestAssignedToRequestBody] = OMIT,
        due_at_time: typing.Optional[dt.datetime] = OMIT,
        is_required: typing.Optional[bool] = OMIT,
        route_stop_id: typing.Optional[str] = OMIT,
        status: typing.Optional[FormSubmissionsPatchFormSubmissionRequestBodyStatus] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsPatchFormSubmissionResponseBody:
        """
        Updates an instance of a form submission.

         <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 Form Submissions** under the Forms 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
        ----------
        id : str
            ID of the form submission.

        approval_details : typing.Optional[FormSubmissionRequestApprovalDetailsRequestBody]

        assigned_to : typing.Optional[FormSubmissionRequestAssignedToRequestBody]

        due_at_time : typing.Optional[dt.datetime]
            Due date of the form submission. UTC timestamp in RFC 3339 format.

        is_required : typing.Optional[bool]
            Indicates whether the worker is required to complete this form or not at a specific route stop. Defaults to `true` if the form is assigned to a user or driver. When true, the worker cannot depart the route stop until this form submission is `submitted`.

        route_stop_id : typing.Optional[str]
            ID of the route stop the form submission is assigned to. Must be a unique Samsara ID.

        status : typing.Optional[FormSubmissionsPatchFormSubmissionRequestBodyStatus]
            Status of the form submission.  Valid values: `notStarted`, `archived`, `inProgress`, `changesRequested`, `approved`

        title : typing.Optional[str]
            Title of the form submission.

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

        Returns
        -------
        FormSubmissionsPatchFormSubmissionResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.patch_form_submission(
            id="9814a1fa-f0c6-408b-bf85-51dc3bc71ac8",
            status="notStarted",
        )
        """
        _response = self._raw_client.patch_form_submission(
            id=id,
            approval_details=approval_details,
            assigned_to=assigned_to,
            due_at_time=due_at_time,
            is_required=is_required,
            route_stop_id=route_stop_id,
            status=status,
            title=title,
            request_options=request_options,
        )
        return _response.data

    def get_form_submissions_pdf_exports(
        self, *, pdf_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> FormSubmissionsGetFormSubmissionsPdfExportsResponseBody:
        """
        Returns a PDF export that has already been generated for a form submission.

         <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 **Read Form Submissions** under the Forms 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
        ----------
        pdf_id : str
            ID of the form submission PDF export.

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

        Returns
        -------
        FormSubmissionsGetFormSubmissionsPdfExportsResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.get_form_submissions_pdf_exports(
            pdf_id="pdfId",
        )
        """
        _response = self._raw_client.get_form_submissions_pdf_exports(pdf_id=pdf_id, request_options=request_options)
        return _response.data

    def post_form_submissions_pdf_exports(
        self, *, id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> FormSubmissionsPostFormSubmissionsPdfExportsResponseBody:
        """
        Creates a PDF export for an existing form submission.

         <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 Form Submissions** under the Forms 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
        ----------
        id : str
            ID of the form submission to create a PDF export from.

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

        Returns
        -------
        FormSubmissionsPostFormSubmissionsPdfExportsResponseBody
            Accepted response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.post_form_submissions_pdf_exports(
            id="id",
        )
        """
        _response = self._raw_client.post_form_submissions_pdf_exports(id=id, request_options=request_options)
        return _response.data

    def get_form_submissions_stream(
        self,
        *,
        start_time: str,
        end_time: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        form_template_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        user_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        assigned_to_route_stop_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsGetFormSubmissionsStreamResponseBody:
        """
        Returns all form submissions data that has been created or modified for your organization based on the time parameters passed in. Results are paginated and are sorted by last modified date. If you include an endTime, the endpoint will return data up until that point (exclusive). If you don’t include an endTime, you can continue to poll the API real-time with the pagination cursor that gets returned on every call.

         <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 Form Submissions** under the Forms 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. Millisecond precision and timezones are supported. Value is compared against `updatedAtTime`. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).

        end_time : typing.Optional[str]
            An end time in RFC 3339 format. Defaults to now if not provided. Millisecond precision and timezones are supported. Value is compared against `updatedAtTime`. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).

        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.

        form_template_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 template IDs to filter data to.

        user_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 user IDs to filter data to.

        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 user IDs to filter data to.

        include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of strings indicating whether to return additional information. Valid values: `externalIds`

        assigned_to_route_stop_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 route stop IDs to filter data to.

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

        Returns
        -------
        FormSubmissionsGetFormSubmissionsStreamResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.get_form_submissions_stream(
            start_time="startTime",
        )
        """
        _response = self._raw_client.get_form_submissions_stream(
            start_time=start_time,
            end_time=end_time,
            after=after,
            form_template_ids=form_template_ids,
            user_ids=user_ids,
            driver_ids=driver_ids,
            include=include,
            assigned_to_route_stop_ids=assigned_to_route_stop_ids,
            request_options=request_options,
        )
        return _response.data

    def get_form_templates(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormTemplatesGetFormTemplatesResponseBody:
        """
        Returns a list of the organization's form templates for the specified list of IDs. If no IDs are provided, all form templates for the organization will be returned.

         <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 Form Submissions** under the Forms 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
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 100 template IDs to filter on.

        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
        -------
        FormTemplatesGetFormTemplatesResponseBody
            OK response.

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

        client = Samsara(
            token="YOUR_TOKEN",
        )
        client.forms.get_form_templates()
        """
        _response = self._raw_client.get_form_templates(ids=ids, after=after, request_options=request_options)
        return _response.data


class AsyncFormsClient:
    def __init__(self, *, client_wrapper: AsyncClientWrapper):
        self._raw_client = AsyncRawFormsClient(client_wrapper=client_wrapper)

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

        Returns
        -------
        AsyncRawFormsClient
        """
        return self._raw_client

    async def get_form_submissions(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsGetFormSubmissionsResponseBody:
        """
        Returns all form submissions data for the specified list of IDs.

         <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 Form Submissions** under the Forms 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
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 100 form submission IDs to filter on. Can be either a unique Samsara ID or an [external ID](https://developers.samsara.com/docs/external-ids) for the form submission.

        include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of strings indicating whether to return additional information. Valid values: `externalIds`

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

        Returns
        -------
        FormSubmissionsGetFormSubmissionsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.get_form_submissions()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_form_submissions(
            ids=ids, include=include, request_options=request_options
        )
        return _response.data

    async def post_form_submission(
        self,
        *,
        form_template: FormTemplateRequestObjectRequestBody,
        status: FormSubmissionsPostFormSubmissionRequestBodyStatus,
        assigned_to: typing.Optional[FormSubmissionRequestAssignedToRequestBody] = OMIT,
        due_at_time: typing.Optional[dt.datetime] = OMIT,
        fields: typing.Optional[typing.Sequence[FormSubmissionRequestFieldInputObjectRequestBody]] = OMIT,
        is_required: typing.Optional[bool] = OMIT,
        route_stop_id: typing.Optional[str] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsPostFormSubmissionResponseBody:
        """
        Creates a form submission and assigns it to an individual worker. This endpoint can be used to create an empty or partially complete form submission and assign it to a worker.

         <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 Form Submissions** under the Forms 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
        ----------
        form_template : FormTemplateRequestObjectRequestBody

        status : FormSubmissionsPostFormSubmissionRequestBodyStatus
            Status of the form submission.  Valid values: `notStarted`

        assigned_to : typing.Optional[FormSubmissionRequestAssignedToRequestBody]

        due_at_time : typing.Optional[dt.datetime]
            Due date of the form submission. UTC timestamp in RFC 3339 format.

        fields : typing.Optional[typing.Sequence[FormSubmissionRequestFieldInputObjectRequestBody]]
            List of field inputs in a form submission.

        is_required : typing.Optional[bool]
            Indicates whether the worker is required to complete this form or not at a specific route stop. Defaults to `true` if the form is assigned to a user or driver. When true, the worker cannot depart the route stop until this form submission is `submitted`.

        route_stop_id : typing.Optional[str]
            ID of the route stop the form submission is assigned to. Must be a unique Samsara ID.

        title : typing.Optional[str]
            Title of the form submission.

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

        Returns
        -------
        FormSubmissionsPostFormSubmissionResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara, FormTemplateRequestObjectRequestBody

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.post_form_submission(
                form_template=FormTemplateRequestObjectRequestBody(
                    id="9814a1fa-f0c6-408b-bf85-51dc3bc71ac7",
                    revision_id="1214a1fa-f0c6-408b-bf85-51dc3bc71ac7",
                ),
                status="notStarted",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.post_form_submission(
            form_template=form_template,
            status=status,
            assigned_to=assigned_to,
            due_at_time=due_at_time,
            fields=fields,
            is_required=is_required,
            route_stop_id=route_stop_id,
            title=title,
            request_options=request_options,
        )
        return _response.data

    async def patch_form_submission(
        self,
        *,
        id: str,
        approval_details: typing.Optional[FormSubmissionRequestApprovalDetailsRequestBody] = OMIT,
        assigned_to: typing.Optional[FormSubmissionRequestAssignedToRequestBody] = OMIT,
        due_at_time: typing.Optional[dt.datetime] = OMIT,
        is_required: typing.Optional[bool] = OMIT,
        route_stop_id: typing.Optional[str] = OMIT,
        status: typing.Optional[FormSubmissionsPatchFormSubmissionRequestBodyStatus] = OMIT,
        title: typing.Optional[str] = OMIT,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsPatchFormSubmissionResponseBody:
        """
        Updates an instance of a form submission.

         <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 Form Submissions** under the Forms 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
        ----------
        id : str
            ID of the form submission.

        approval_details : typing.Optional[FormSubmissionRequestApprovalDetailsRequestBody]

        assigned_to : typing.Optional[FormSubmissionRequestAssignedToRequestBody]

        due_at_time : typing.Optional[dt.datetime]
            Due date of the form submission. UTC timestamp in RFC 3339 format.

        is_required : typing.Optional[bool]
            Indicates whether the worker is required to complete this form or not at a specific route stop. Defaults to `true` if the form is assigned to a user or driver. When true, the worker cannot depart the route stop until this form submission is `submitted`.

        route_stop_id : typing.Optional[str]
            ID of the route stop the form submission is assigned to. Must be a unique Samsara ID.

        status : typing.Optional[FormSubmissionsPatchFormSubmissionRequestBodyStatus]
            Status of the form submission.  Valid values: `notStarted`, `archived`, `inProgress`, `changesRequested`, `approved`

        title : typing.Optional[str]
            Title of the form submission.

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

        Returns
        -------
        FormSubmissionsPatchFormSubmissionResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.patch_form_submission(
                id="9814a1fa-f0c6-408b-bf85-51dc3bc71ac8",
                status="notStarted",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.patch_form_submission(
            id=id,
            approval_details=approval_details,
            assigned_to=assigned_to,
            due_at_time=due_at_time,
            is_required=is_required,
            route_stop_id=route_stop_id,
            status=status,
            title=title,
            request_options=request_options,
        )
        return _response.data

    async def get_form_submissions_pdf_exports(
        self, *, pdf_id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> FormSubmissionsGetFormSubmissionsPdfExportsResponseBody:
        """
        Returns a PDF export that has already been generated for a form submission.

         <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 **Read Form Submissions** under the Forms 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
        ----------
        pdf_id : str
            ID of the form submission PDF export.

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

        Returns
        -------
        FormSubmissionsGetFormSubmissionsPdfExportsResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.get_form_submissions_pdf_exports(
                pdf_id="pdfId",
            )


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

    async def post_form_submissions_pdf_exports(
        self, *, id: str, request_options: typing.Optional[RequestOptions] = None
    ) -> FormSubmissionsPostFormSubmissionsPdfExportsResponseBody:
        """
        Creates a PDF export for an existing form submission.

         <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 Form Submissions** under the Forms 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
        ----------
        id : str
            ID of the form submission to create a PDF export from.

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

        Returns
        -------
        FormSubmissionsPostFormSubmissionsPdfExportsResponseBody
            Accepted response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.post_form_submissions_pdf_exports(
                id="id",
            )


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

    async def get_form_submissions_stream(
        self,
        *,
        start_time: str,
        end_time: typing.Optional[str] = None,
        after: typing.Optional[str] = None,
        form_template_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        user_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        driver_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        include: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        assigned_to_route_stop_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormSubmissionsGetFormSubmissionsStreamResponseBody:
        """
        Returns all form submissions data that has been created or modified for your organization based on the time parameters passed in. Results are paginated and are sorted by last modified date. If you include an endTime, the endpoint will return data up until that point (exclusive). If you don’t include an endTime, you can continue to poll the API real-time with the pagination cursor that gets returned on every call.

         <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 Form Submissions** under the Forms 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. Millisecond precision and timezones are supported. Value is compared against `updatedAtTime`. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).

        end_time : typing.Optional[str]
            An end time in RFC 3339 format. Defaults to now if not provided. Millisecond precision and timezones are supported. Value is compared against `updatedAtTime`. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).

        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.

        form_template_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 template IDs to filter data to.

        user_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 user IDs to filter data to.

        driver_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 user IDs to filter data to.

        include : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list of strings indicating whether to return additional information. Valid values: `externalIds`

        assigned_to_route_stop_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 50 route stop IDs to filter data to.

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

        Returns
        -------
        FormSubmissionsGetFormSubmissionsStreamResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.get_form_submissions_stream(
                start_time="startTime",
            )


        asyncio.run(main())
        """
        _response = await self._raw_client.get_form_submissions_stream(
            start_time=start_time,
            end_time=end_time,
            after=after,
            form_template_ids=form_template_ids,
            user_ids=user_ids,
            driver_ids=driver_ids,
            include=include,
            assigned_to_route_stop_ids=assigned_to_route_stop_ids,
            request_options=request_options,
        )
        return _response.data

    async def get_form_templates(
        self,
        *,
        ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
        after: typing.Optional[str] = None,
        request_options: typing.Optional[RequestOptions] = None,
    ) -> FormTemplatesGetFormTemplatesResponseBody:
        """
        Returns a list of the organization's form templates for the specified list of IDs. If no IDs are provided, all form templates for the organization will be returned.

         <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 Form Submissions** under the Forms 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
        ----------
        ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
            A comma-separated list containing up to 100 template IDs to filter on.

        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
        -------
        FormTemplatesGetFormTemplatesResponseBody
            OK response.

        Examples
        --------
        import asyncio

        from samsara import AsyncSamsara

        client = AsyncSamsara(
            token="YOUR_TOKEN",
        )


        async def main() -> None:
            await client.forms.get_form_templates()


        asyncio.run(main())
        """
        _response = await self._raw_client.get_form_templates(ids=ids, after=after, request_options=request_options)
        return _response.data
