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

from .webhook_event_base import WebhookEventBase
import typing
import pydantic
from .webhook_event_chat_status import WebhookEventChatStatus
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class WebhookEventChatEnded(WebhookEventBase):
    event_name: typing.Optional[typing.Literal["chat_ended"]] = pydantic.Field(default=None)
    """
    Always `chat_ended`.
    """

    end_time: int
    duration_seconds: int
    end_reason: WebhookEventChatStatus
    caller_number: typing.Optional[str] = None
    custom_session_id: typing.Optional[str] = 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
