# coding: utf-8

"""
    FastAPI

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

    The version of the OpenAPI document: 0.1.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
from typing import Any, ClassVar, Dict, List, Optional, Union
from voiceos.models.agent_cost import AgentCost
from voiceos.models.currency import Currency
from voiceos.models.language_model_cost import LanguageModelCost
from voiceos.models.synthesizer_cost import SynthesizerCost
from voiceos.models.telephony_cost import TelephonyCost
from voiceos.models.transcriber_cost import TranscriberCost
from typing import Optional, Set
from typing_extensions import Self

class CallCost(BaseModel):
    """
    CallCost
    """ # noqa: E501
    total: Union[StrictFloat, StrictInt] = Field(description="The total cost of the call.")
    synthesizer: SynthesizerCost = Field(description="The synthetizer cost.")
    transcriber: TranscriberCost = Field(description="The transcriber cost.")
    language_model: LanguageModelCost = Field(description="The language model cost.")
    telephony: Optional[TelephonyCost] = Field(default=None, description="The telephony cost. Returns null if the call was not a phone call.")
    agent: AgentCost = Field(description="The cost of the agent.")
    currency: Optional[Currency] = Field(default=None, description="The currency used. As of now, we only offer USD.")
    __properties: ClassVar[List[str]] = ["total", "synthesizer", "transcriber", "language_model", "telephony", "agent", "currency"]

    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 CallCost 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 synthesizer
        if self.synthesizer:
            _dict['synthesizer'] = self.synthesizer.to_dict()
        # override the default output from pydantic by calling `to_dict()` of transcriber
        if self.transcriber:
            _dict['transcriber'] = self.transcriber.to_dict()
        # override the default output from pydantic by calling `to_dict()` of language_model
        if self.language_model:
            _dict['language_model'] = self.language_model.to_dict()
        # override the default output from pydantic by calling `to_dict()` of telephony
        if self.telephony:
            _dict['telephony'] = self.telephony.to_dict()
        # 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 CallCost from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "total": obj.get("total"),
            "synthesizer": SynthesizerCost.from_dict(obj["synthesizer"]) if obj.get("synthesizer") is not None else None,
            "transcriber": TranscriberCost.from_dict(obj["transcriber"]) if obj.get("transcriber") is not None else None,
            "language_model": LanguageModelCost.from_dict(obj["language_model"]) if obj.get("language_model") is not None else None,
            "telephony": TelephonyCost.from_dict(obj["telephony"]) if obj.get("telephony") is not None else None,
            "agent": AgentCost.from_dict(obj["agent"]) if obj.get("agent") is not None else None,
            "currency": obj.get("currency")
        })
        return _obj


