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

import datetime as dt
import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .form_submission_response_object_response_body_status import FormSubmissionResponseObjectResponseBodyStatus
from .form_template_reference_object_response_body import FormTemplateReferenceObjectResponseBody
from .forms_asset_object_response_body import FormsAssetObjectResponseBody
from .forms_field_input_object_response_body import FormsFieldInputObjectResponseBody
from .forms_geofence_object_response_body import FormsGeofenceObjectResponseBody
from .forms_location_object_response_body import FormsLocationObjectResponseBody
from .forms_polymorphic_user_object_response_body import FormsPolymorphicUserObjectResponseBody
from .forms_product_submission_approval_details_object_response_body import (
    FormsProductSubmissionApprovalDetailsObjectResponseBody,
)
from .forms_score_object_response_body import FormsScoreObjectResponseBody


class FormSubmissionResponseObjectResponseBody(UniversalBaseModel):
    """
    Form Submission response object.
    """

    approval_details: typing_extensions.Annotated[
        typing.Optional[FormsProductSubmissionApprovalDetailsObjectResponseBody],
        FieldMetadata(alias="approvalDetails"),
        pydantic.Field(alias="approvalDetails"),
    ] = None
    asset: typing.Optional[FormsAssetObjectResponseBody] = None
    assigned_at_time: typing_extensions.Annotated[
        typing.Optional[dt.datetime],
        FieldMetadata(alias="assignedAtTime"),
        pydantic.Field(
            alias="assignedAtTime",
            description="Assignment time of the form submission. Sometimes returned if the submission was assigned to a user or driver. UTC timestamp in RFC 3339 format.",
        ),
    ] = None
    assigned_to: typing_extensions.Annotated[
        typing.Optional[FormsPolymorphicUserObjectResponseBody],
        FieldMetadata(alias="assignedTo"),
        pydantic.Field(alias="assignedTo"),
    ] = None
    created_at_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="createdAtTime"),
        pydantic.Field(
            alias="createdAtTime", description="Creation time of the form submission. UTC timestamp in RFC 3339 format."
        ),
    ]
    due_at_time: typing_extensions.Annotated[
        typing.Optional[dt.datetime],
        FieldMetadata(alias="dueAtTime"),
        pydantic.Field(
            alias="dueAtTime",
            description="Time of when the submission is due. Sometimes returned, if the submission has a due date. UTC timestamp in RFC 3339 format.",
        ),
    ] = None
    external_ids: typing_extensions.Annotated[
        typing.Optional[typing.Dict[str, str]],
        FieldMetadata(alias="externalIds"),
        pydantic.Field(alias="externalIds", description="A map of external ids"),
    ] = None
    fields: typing.List[FormsFieldInputObjectResponseBody] = pydantic.Field()
    """
    List of field inputs in a form submission.
    """

    form_template: typing_extensions.Annotated[
        FormTemplateReferenceObjectResponseBody,
        FieldMetadata(alias="formTemplate"),
        pydantic.Field(alias="formTemplate"),
    ]
    geofence: typing.Optional[FormsGeofenceObjectResponseBody] = None
    id: str = pydantic.Field()
    """
    ID of the form submission.
    """

    is_required: typing_extensions.Annotated[
        bool,
        FieldMetadata(alias="isRequired"),
        pydantic.Field(
            alias="isRequired",
            description="Indicates whether the worker is required to complete this form or not. Always returned.",
        ),
    ]
    location: typing.Optional[FormsLocationObjectResponseBody] = None
    route_id: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="routeId"),
        pydantic.Field(
            alias="routeId",
            description="ID of the route. Sometimes returned if the submission was assigned to a route stop.",
        ),
    ] = None
    route_stop_id: typing_extensions.Annotated[
        typing.Optional[str],
        FieldMetadata(alias="routeStopId"),
        pydantic.Field(
            alias="routeStopId",
            description="ID of the route stop. Sometimes returned if the submission was assigned to a route stop.",
        ),
    ] = None
    score: typing.Optional[FormsScoreObjectResponseBody] = None
    status: FormSubmissionResponseObjectResponseBodyStatus = pydantic.Field()
    """
    State for the Form Submission. Always returned.  Valid values: `notStarted`, `completed`, `archived`, `inProgress`, `needsReview`, `changesRequested`, `approved`
    """

    submitted_at_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="submittedAtTime"),
        pydantic.Field(
            alias="submittedAtTime",
            description="Submission time of the form submission. UTC timestamp in RFC 3339 format.",
        ),
    ]
    submitted_by: typing_extensions.Annotated[
        FormsPolymorphicUserObjectResponseBody, FieldMetadata(alias="submittedBy"), pydantic.Field(alias="submittedBy")
    ]
    title: typing.Optional[str] = pydantic.Field(default=None)
    """
    Title of the form submission. Sometimes returned if the submission has a title.
    """

    updated_at_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="updatedAtTime"),
        pydantic.Field(
            alias="updatedAtTime", description="Update time of the form submission. UTC timestamp in RFC 3339 format."
        ),
    ]

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
