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

import datetime as dt
import typing

from ...core.datetime_utils import serialize_datetime
from .call_length import CallLength
from .queue_status import QueueStatus

try:
    import pydantic.v1 as pydantic  # type: ignore
except ImportError:
    import pydantic  # type: ignore


class AnalysisObject(pydantic.BaseModel):
    """
    from blandai import AnalysisObject, CallLength, CallLengthSummary, QueueStatus

    AnalysisObject(
        total_calls=3,
        completed_calls=2,
        in_progress_calls=1,
        queue_statuses=QueueStatus(
            complete=2,
            queued=1,
            call_error=0,
        ),
        call_lengths=CallLength(
            average=7,
            average_nonzero=7,
            summary=CallLengthSummary(
                _0_5=2,
                _5_10=0,
                _10_15=1,
                _15_20=0,
                _20_30=0,
                _30_45=0,
                _45_60=0,
                _60_90=0,
                _90_120=0,
                _120=0,
            ),
            all=[5, 5, 11],
        ),
        call_ids=[
            "73c809a9-db35-4edb-8fa6-95a6a942daf8",
            "73c809a9-db35-4edb-8fa6-95a6a942daf9",
            "73c809a9-db35-4edb-8fa6-95a6a942daf0",
        ],
        error_messages=[
            "Cannot transfer to +12223334444 - Call is no longer active."
        ],
        endpoints={"API": "3"},
    )
    """

    total_calls: int = pydantic.Field()
    """
    The total number of calls in the batch, including completed and in-progress calls.
    """

    completed_calls: int = pydantic.Field()
    """
    The total number of completed calls in the batch.
    """

    in_progress_calls: int = pydantic.Field()
    """
    The total number of in-progress calls in the batch.
    """

    queue_statuses: QueueStatus = pydantic.Field()
    """
    An object containing the number of calls in each queue status.
    """

    call_lengths: CallLength = pydantic.Field()
    """
    Contains `average`, `average_nonzero`, `summary` and `all` fields.
    """

    call_ids: typing.List[str] = pydantic.Field()
    """
    Contains each `call_id` in the batch.
    """

    error_messages: typing.List[str] = pydantic.Field()
    """
    Contains any error messages that calls in the batch may have.
    """

    endpoints: typing.Dict[str, str] = pydantic.Field()
    """
    Contains the number of calls that have been sent to each endpoint. Applicable only to API integrations.
    """

    def json(self, **kwargs: typing.Any) -> str:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().json(**kwargs_with_defaults)

    def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
        kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
        return super().dict(**kwargs_with_defaults)

    class Config:
        frozen = True
        smart_union = True
        json_encoders = {dt.datetime: serialize_datetime}
