# 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


class FallbackMessage(UniversalBaseModel):
    """
    SMS/MMS fallback message to send if the RCS message fails to deliver.

    When a recipient's device doesn't support RCS, this fallback message will be sent as SMS or MMS instead. The fallback is sent from the specified phone number.

    > **Note:** At least one of `text` or `mediaUrls` must be provided. Fallback messages require a verified `from` phone number with SMS/MMS sending capabilities.

    > **Billing:** You will be charged the standard SMS or MMS rate for the fallback message. The original RCS message will not be charged if the fallback is sent instead.
    """

    from_: typing_extensions.Annotated[str, FieldMetadata(alias="from")] = pydantic.Field()
    """
    Phone number to send the fallback message from in E.164 format.
    
    Must be a verified phone number with SMS/MMS sending capabilities. Sandbox numbers cannot be used for fallbacks. The phone number must be connected to an active toll-free or 10DLC campaign.
    """

    text: typing.Optional[str] = pydantic.Field(default=None)
    """
    Text content for the fallback message.
    
    At least one of `text` or `mediaUrls` must be provided.
    
    If `mediaUrls` is empty and the text fits within SMS segment limits, the fallback will be sent as SMS. Otherwise, it will be sent as MMS. You will only be billed for the message sent.
    """

    media_urls: typing_extensions.Annotated[typing.Optional[typing.List[str]], FieldMetadata(alias="mediaUrls")] = (
        pydantic.Field(default=None)
    )
    """
    Media file URLs to include in the fallback MMS message.
    
    See [supported media types](https://app.pinnacle.sh/supported-file-types?type=MMS).
    
    If provided, the fallback will be sent as MMS. Otherwise, it will be sent as SMS (if text fits within segment limits). At least one of `text` or `mediaUrls` must be provided.
    """

    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
