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

import typing

import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2
from ...core.unchecked_base_model import UncheckedBaseModel
from .get_telephony_response_reason import GetTelephonyResponseReason
from .get_telephony_response_state import GetTelephonyResponseState
from .get_telephony_response_type import GetTelephonyResponseType


class GetTelephonyResponse(UncheckedBaseModel):
    to_number: typing.Optional[str] = pydantic.Field(default=None)
    """
    The number called.
    """

    from_number: typing.Optional[str] = pydantic.Field(default=None)
    """
    Caller ID.
    """

    pipeline_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    The unique ID of a published project in AI Studio. Can be obtained in AI Studio - Project - Release Management.
    """

    type: typing.Optional[GetTelephonyResponseType] = pydantic.Field(default=None)
    """
    Call type:
    - `inbound`: Inbound call.
    - `outbound`: Outbound call.
    """

    agent_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    A unique identifier for the call session.
    """

    channel: typing.Optional[str] = pydantic.Field(default=None)
    """
    RTC channel name.
    """

    reason: typing.Optional[GetTelephonyResponseReason] = pydantic.Field(default=None)
    """
    Reason for call ending:
    - `request`: Actively hung up.
    - `hangup`: The other party hung up.
    - `failed`: Call failed.
    """

    create_ts: typing.Optional[int] = pydantic.Field(default=None)
    """
    Call creation timestamp (in seconds).
    """

    state: typing.Optional[GetTelephonyResponseState] = pydantic.Field(default=None)
    """
    Call status:
    - `answered`: The call was answered.
    - `hangup`: The call was disconnected.
    """

    stop_ts: typing.Optional[int] = pydantic.Field(default=None)
    """
    Call end timestamp (in seconds). Returns `0` or `null` if the call has not ended.
    """

    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
