# coding: utf-8

"""
    Agent Management API

    API for managing agents, their templates, and call logs

    The version of the OpenAPI document: 1.0.0
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


from __future__ import annotations
import pprint
import re  # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from smallestai.atoms.models.agent_dto import AgentDTO
from typing import Optional, Set
from typing_extensions import Self

class GetConversationLogs200ResponseData(BaseModel):
    """
    GetConversationLogs200ResponseData
    """ # noqa: E501
    id: Optional[StrictStr] = Field(default=None, description="The ID of the conversation", alias="_id")
    call_id: Optional[StrictStr] = Field(default=None, description="The ID of the conversation", alias="callId")
    agent: Optional[AgentDTO] = None
    status: Optional[StrictStr] = Field(default=None, description="The status of the conversation")
    duration: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The duration of the conversation in seconds")
    recording_url: Optional[StrictStr] = Field(default=None, description="The recording URL of the conversation", alias="recordingUrl")
    var_from: Optional[StrictStr] = Field(default=None, description="The phone number of the caller", alias="from")
    to: Optional[StrictStr] = Field(default=None, description="The phone number of the callee")
    transcript: Optional[List[StrictStr]] = Field(default=None, description="The transcript of the conversation")
    average_transcriber_latency: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The average time taken by the TTS to transcribe the conversation")
    average_agent_latency: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The average time taken by the LLM to respond to the conversation")
    average_synthesizer_latency: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The average time taken by the TTS to synthesize the conversation")
    type: Optional[StrictStr] = Field(default=None, description="The type of the conversation")
    __properties: ClassVar[List[str]] = ["_id", "callId", "agent", "status", "duration", "recordingUrl", "from", "to", "transcript", "average_transcriber_latency", "average_agent_latency", "average_synthesizer_latency", "type"]

    @field_validator('type')
    def type_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['telephony_inbound', 'telephony_outbound', 'chat']):
            raise ValueError("must be one of enum values ('telephony_inbound', 'telephony_outbound', 'chat')")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.model_dump(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of GetConversationLogs200ResponseData from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        # override the default output from pydantic by calling `to_dict()` of agent
        if self.agent:
            _dict['agent'] = self.agent.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of GetConversationLogs200ResponseData from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "_id": obj.get("_id"),
            "callId": obj.get("callId"),
            "agent": AgentDTO.from_dict(obj["agent"]) if obj.get("agent") is not None else None,
            "status": obj.get("status"),
            "duration": obj.get("duration"),
            "recordingUrl": obj.get("recordingUrl"),
            "from": obj.get("from"),
            "to": obj.get("to"),
            "transcript": obj.get("transcript"),
            "average_transcriber_latency": obj.get("average_transcriber_latency"),
            "average_agent_latency": obj.get("average_agent_latency"),
            "average_synthesizer_latency": obj.get("average_synthesizer_latency"),
            "type": obj.get("type")
        })
        return _obj


