# 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_summary_direction import MessageSummaryDirection
from .message_summary_method import MessageSummaryMethod
from .message_summary_status import MessageSummaryStatus
from .message_summary_type import MessageSummaryType


class MessageSummary(UniversalBaseModel):
    id: str = pydantic.Field()
    """
    Unique identifier for the message.
    """

    status: MessageSummaryStatus = pydantic.Field()
    """
    Current status of the message.
    """

    direction: MessageSummaryDirection = pydantic.Field()
    """
    Direction of the message.
    """

    type: MessageSummaryType = pydantic.Field()
    """
    Protocol type of the message.
    """

    method: MessageSummaryMethod = pydantic.Field()
    """
    Method used to send the message.
    """

    num_segments: typing_extensions.Annotated[int, FieldMetadata(alias="numSegments")] = pydantic.Field()
    """
    Number of segments in the message.
    """

    cost: typing.Optional[float] = pydantic.Field(default=None)
    """
    Cost of the message.
    """

    from_: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="from")] = pydantic.Field(default=None)
    """
    Sender phone number (E.164) or RCS agent ID.
    """

    to: typing.Optional[str] = pydantic.Field(default=None)
    """
    Recipient phone number in E.164 format.
    """

    content: typing.Dict[str, typing.Optional[typing.Any]] = pydantic.Field()
    """
    Message content (SMS text, MMS media, or RCS rich content).
    """

    error: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
    """
    Error details if the message failed.
    """

    is_test: typing_extensions.Annotated[bool, FieldMetadata(alias="isTest")] = pydantic.Field()
    """
    Whether this is a test message.
    """

    blast_id: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="blastId")] = pydantic.Field(
        default=None
    )
    """
    ID of the blast this message belongs to, if any.
    """

    sent_at: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="sentAt")] = pydantic.Field(
        default=None
    )
    """
    ISO 8601 timestamp of when the message was sent.
    """

    delivered_at: typing_extensions.Annotated[typing.Optional[str], FieldMetadata(alias="deliveredAt")] = (
        pydantic.Field(default=None)
    )
    """
    ISO 8601 timestamp of when the message was delivered.
    """

    created_at: typing_extensions.Annotated[str, FieldMetadata(alias="createdAt")] = pydantic.Field()
    """
    ISO 8601 timestamp of when the message was created.
    """

    updated_at: typing_extensions.Annotated[str, FieldMetadata(alias="updatedAt")] = pydantic.Field()
    """
    ISO 8601 timestamp of when the message was last updated.
    """

    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
