# coding: utf-8

"""
    SmartyMeet Dev03 API REST

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)

    The version of the OpenAPI document: 1.0.1
    Contact: developer@smartymeet.com
    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, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from smartytalent_client.models.resource_timestamps_schema import ResourceTimestampsSchema
from typing import Optional, Set
from typing_extensions import Self
from pydantic_core import to_jsonable_python

class CallAttributesSchema(BaseModel):
    """
    CallAttributesSchema
    """ # noqa: E501
    name: Optional[StrictStr] = Field(default=None, description="Call title, e.g. Inbound call from John")
    direction: Optional[StrictStr] = Field(default=None, description="Call direction")
    call_type: Optional[StrictStr] = Field(default=None, description="Type/purpose of the call", alias="callType")
    duration: Optional[StrictInt] = Field(default=None, description="Call duration in seconds")
    outcome: Optional[StrictStr] = Field(default=None, description="Call outcome")
    caller_number: Optional[StrictStr] = Field(default=None, description="Caller phone number in E.164 format", alias="callerNumber")
    called_number: Optional[StrictStr] = Field(default=None, description="Called phone number in E.164 format", alias="calledNumber")
    call_sid: Optional[StrictStr] = Field(default=None, description="Twilio call SID", alias="callSid")
    transcript: Optional[Dict[str, Any]] = Field(default=None, description="Localized transcript entries keyed by locale (e.g. en-US, pl-PL). Each value is an array of {speaker, speakerType, timestamp, endTimestamp, text}.")
    speaker_stats: Optional[List[Dict[str, Any]]] = Field(default=None, description="Speaker statistics with talk percentages and time segments", alias="speakerStats")
    recording_url: Optional[StrictStr] = Field(default=None, description="URL or S3 path to call recording", alias="recordingUrl")
    has_recording: Optional[StrictBool] = Field(default=None, description="Whether a recording exists for this call", alias="hasRecording")
    has_transcript: Optional[StrictBool] = Field(default=None, description="Whether a transcript exists for this call", alias="hasTranscript")
    attendees: Optional[List[Dict[str, Any]]] = Field(default=None, description="Call attendees with name and role")
    ai_notes: Optional[Dict[str, Any]] = Field(default=None, description="Localized AI-generated notes keyed by locale. Each value contains summary, keyNotes, topicsDiscussed, sentiment.", alias="aiNotes")
    short_code: Optional[StrictStr] = Field(default=None, description="Short code identifier", alias="shortCode")
    status: Optional[StrictStr] = None
    timestamps: Optional[ResourceTimestampsSchema] = None
    __properties: ClassVar[List[str]] = ["name", "direction", "callType", "duration", "outcome", "callerNumber", "calledNumber", "callSid", "transcript", "speakerStats", "recordingUrl", "hasRecording", "hasTranscript", "attendees", "aiNotes", "shortCode", "status", "timestamps"]

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

        if value not in set(['inbound', 'outbound', 'ai-bot']):
            raise ValueError("must be one of enum values ('inbound', 'outbound', 'ai-bot')")
        return value

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

        if value not in set(['candidate-call', 'bot-setup', 'follow-up', 'screening', 'reference-check']):
            raise ValueError("must be one of enum values ('candidate-call', 'bot-setup', 'follow-up', 'screening', 'reference-check')")
        return value

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

        if value not in set(['connected', 'missed', 'voicemail', 'no-answer', 'busy']):
            raise ValueError("must be one of enum values ('connected', 'missed', 'voicemail', 'no-answer', 'busy')")
        return value

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

        if value not in set(['active', 'draft', 'archived', 'failed']):
            raise ValueError("must be one of enum values ('active', 'draft', 'archived', 'failed')")
        return value

    model_config = ConfigDict(
        validate_by_name=True,
        validate_by_alias=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"""
        return json.dumps(to_jsonable_python(self.to_dict()))

    @classmethod
    def from_json(cls, json_str: str) -> Optional[Self]:
        """Create an instance of CallAttributesSchema 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 timestamps
        if self.timestamps:
            _dict['timestamps'] = self.timestamps.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "name": obj.get("name"),
            "direction": obj.get("direction"),
            "callType": obj.get("callType"),
            "duration": obj.get("duration"),
            "outcome": obj.get("outcome"),
            "callerNumber": obj.get("callerNumber"),
            "calledNumber": obj.get("calledNumber"),
            "callSid": obj.get("callSid"),
            "transcript": obj.get("transcript"),
            "speakerStats": obj.get("speakerStats"),
            "recordingUrl": obj.get("recordingUrl"),
            "hasRecording": obj.get("hasRecording"),
            "hasTranscript": obj.get("hasTranscript"),
            "attendees": obj.get("attendees"),
            "aiNotes": obj.get("aiNotes"),
            "shortCode": obj.get("shortCode"),
            "status": obj.get("status"),
            "timestamps": ResourceTimestampsSchema.from_dict(obj["timestamps"]) if obj.get("timestamps") is not None else None
        })
        return _obj


