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

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2, UniversalBaseModel
from ..core.serialization import FieldMetadata
from .message_event_fallback_message_type import MessageEventFallbackMessageType


class MessageEventFallbackMessage(UniversalBaseModel):
    """
    Details of the fallback SMS/MMS message(s) that were actually sent to the recipient instead of the original RCS message.

    Only present when the message `status` is `FALLBACK_SENT`. The `message.id` on this event refers to the original RCS message that could not be delivered. The `fallbackMessage.ids` contain the identifiers of the actual SMS/MMS messages that were sent.
    """

    ids: typing.List[str] = pydantic.Field()
    """
    Unique identifiers of the actual SMS/MMS message(s) that were sent as the fallback. Each identifier always begins with the prefix `msg_`. Multiple IDs indicate the fallback was split into multiple SMS/MMS messages. <br><br>
    These are the messages that were actually delivered to the recipient. To get their full details, use the [GET /messages/{id}](/api-reference/messages/get) endpoint.
    """

    type: MessageEventFallbackMessageType = pydantic.Field()
    """
    Delivery protocol of the fallback message that was sent.
    """

    from_: typing_extensions.Annotated[str, FieldMetadata(alias="from")] = pydantic.Field()
    """
    Phone number the fallback message was sent from in E.164 format.
    """

    to: str = pydantic.Field()
    """
    Recipient's phone number in E.164 format.
    """

    text: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text content of the fallback message.
    """

    media_urls: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="mediaUrls")] = (
        pydantic.Field(default=None)
    )
    """
    Media URLs included in the fallback MMS message. Empty array for SMS fallbacks.
    """

    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
