# 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 .route_event_details_response_body import RouteEventDetailsResponseBody
from .route_event_response_response_body_event_type import RouteEventResponseResponseBodyEventType
from .route_event_route_response_response_body import RouteEventRouteResponseResponseBody
from .route_event_stop_response_response_body import RouteEventStopResponseResponseBody


class RouteEventResponseResponseBody(UniversalBaseModel):
    """
    A single route event.
    """

    event_details: typing_extensions.Annotated[
        typing.Optional[RouteEventDetailsResponseBody],
        FieldMetadata(alias="eventDetails"),
        pydantic.Field(alias="eventDetails"),
    ] = None
    event_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="eventTime"),
        pydantic.Field(alias="eventTime", description="Time the event was processed in RFC 3339 format"),
    ]
    event_type: typing_extensions.Annotated[
        RouteEventResponseResponseBodyEventType,
        FieldMetadata(alias="eventType"),
        pydantic.Field(
            alias="eventType",
            description="Type of the event that occurred.  Valid values: `stopArrived`, `stopCompleted`, `stopEnRoute`, `stopSkipped`, `stopTaskCompleted`, `stopTaskSkipped`, `stopEtaUpdated`, `unspecified`",
        ),
    ]
    happened_at_time: typing_extensions.Annotated[
        dt.datetime,
        FieldMetadata(alias="happenedAtTime"),
        pydantic.Field(alias="happenedAtTime", description="Time the event happened in RFC 3339 format"),
    ]
    id: str = pydantic.Field()
    """
    Unique ID of the route event.
    """

    route: RouteEventRouteResponseResponseBody
    stop: typing.Optional[RouteEventStopResponseResponseBody] = None

    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
