# coding: utf-8

"""
Mozart platform API

API for interacting with the Mozart platform.

The version of the OpenAPI document: 0.2.0
Contact: support@bang-olufsen.dk
Generated by OpenAPI Generator (https://openapi-generator.tech)

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

from __future__ import annotations

import json
import pprint
import re  # noqa: F401
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field
from typing_extensions import Annotated, Self

from mozart_api.models.advanced_beamforming import AdvancedBeamforming
from mozart_api.models.ambience import Ambience
from mozart_api.models.balance import Balance
from mozart_api.models.bass_management import BassManagement
from mozart_api.models.compression import Compression
from mozart_api.models.directivity import Directivity
from mozart_api.models.fader import Fader
from mozart_api.models.room_compensation import RoomCompensation
from mozart_api.models.spatial_envelopment import SpatialEnvelopment
from mozart_api.models.spatial_height import SpatialHeight
from mozart_api.models.spatial_processing import SpatialProcessing
from mozart_api.models.spatial_surround import SpatialSurround
from mozart_api.models.spatial_width import SpatialWidth
from mozart_api.models.speech_enhance import SpeechEnhance
from mozart_api.models.tone_touch import ToneTouch


class ListeningModeFeatures(BaseModel):
    """
    Sound features to apply
    """  # noqa: E501

    advanced_beamforming: Annotated[
        Optional[AdvancedBeamforming], Field(alias="advancedBeamforming")
    ] = None
    ambience: Optional[Ambience] = None
    balance: Optional[Balance] = None
    bass_management: Annotated[
        Optional[BassManagement], Field(alias="bassManagement")
    ] = None
    compression: Optional[Compression] = None
    directivity: Optional[Directivity] = None
    fader: Optional[Fader] = None
    room_compensation: Annotated[
        Optional[RoomCompensation], Field(alias="roomCompensation")
    ] = None
    spatial_envelopment: Annotated[
        Optional[SpatialEnvelopment], Field(alias="spatialEnvelopment")
    ] = None
    spatial_height: Annotated[Optional[SpatialHeight], Field(alias="spatialHeight")] = (
        None
    )
    spatial_processing: Annotated[
        Optional[SpatialProcessing], Field(alias="spatialProcessing")
    ] = None
    spatial_surround: Annotated[
        Optional[SpatialSurround], Field(alias="spatialSurround")
    ] = None
    spatial_width: Annotated[Optional[SpatialWidth], Field(alias="spatialWidth")] = None
    speech_enhance: Annotated[Optional[SpeechEnhance], Field(alias="speechEnhance")] = (
        None
    )
    tone_touch: Annotated[Optional[ToneTouch], Field(alias="toneTouch")] = None
    __properties: ClassVar[List[str]] = [
        "advancedBeamforming",
        "ambience",
        "balance",
        "bassManagement",
        "compression",
        "directivity",
        "fader",
        "roomCompensation",
        "spatialEnvelopment",
        "spatialHeight",
        "spatialProcessing",
        "spatialSurround",
        "spatialWidth",
        "speechEnhance",
        "toneTouch",
    ]

    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 ListeningModeFeatures 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 advanced_beamforming
        if self.advanced_beamforming:
            _dict["advancedBeamforming"] = self.advanced_beamforming.to_dict()
        # override the default output from pydantic by calling `to_dict()` of ambience
        if self.ambience:
            _dict["ambience"] = self.ambience.to_dict()
        # override the default output from pydantic by calling `to_dict()` of balance
        if self.balance:
            _dict["balance"] = self.balance.to_dict()
        # override the default output from pydantic by calling `to_dict()` of bass_management
        if self.bass_management:
            _dict["bassManagement"] = self.bass_management.to_dict()
        # override the default output from pydantic by calling `to_dict()` of compression
        if self.compression:
            _dict["compression"] = self.compression.to_dict()
        # override the default output from pydantic by calling `to_dict()` of directivity
        if self.directivity:
            _dict["directivity"] = self.directivity.to_dict()
        # override the default output from pydantic by calling `to_dict()` of fader
        if self.fader:
            _dict["fader"] = self.fader.to_dict()
        # override the default output from pydantic by calling `to_dict()` of room_compensation
        if self.room_compensation:
            _dict["roomCompensation"] = self.room_compensation.to_dict()
        # override the default output from pydantic by calling `to_dict()` of spatial_envelopment
        if self.spatial_envelopment:
            _dict["spatialEnvelopment"] = self.spatial_envelopment.to_dict()
        # override the default output from pydantic by calling `to_dict()` of spatial_height
        if self.spatial_height:
            _dict["spatialHeight"] = self.spatial_height.to_dict()
        # override the default output from pydantic by calling `to_dict()` of spatial_processing
        if self.spatial_processing:
            _dict["spatialProcessing"] = self.spatial_processing.to_dict()
        # override the default output from pydantic by calling `to_dict()` of spatial_surround
        if self.spatial_surround:
            _dict["spatialSurround"] = self.spatial_surround.to_dict()
        # override the default output from pydantic by calling `to_dict()` of spatial_width
        if self.spatial_width:
            _dict["spatialWidth"] = self.spatial_width.to_dict()
        # override the default output from pydantic by calling `to_dict()` of speech_enhance
        if self.speech_enhance:
            _dict["speechEnhance"] = self.speech_enhance.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tone_touch
        if self.tone_touch:
            _dict["toneTouch"] = self.tone_touch.to_dict()
        return _dict

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

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

        _obj = cls.model_validate({
            "advancedBeamforming": AdvancedBeamforming.from_dict(
                obj["advancedBeamforming"]
            )
            if obj.get("advancedBeamforming") is not None
            else None,
            "ambience": Ambience.from_dict(obj["ambience"])
            if obj.get("ambience") is not None
            else None,
            "balance": Balance.from_dict(obj["balance"])
            if obj.get("balance") is not None
            else None,
            "bassManagement": BassManagement.from_dict(obj["bassManagement"])
            if obj.get("bassManagement") is not None
            else None,
            "compression": Compression.from_dict(obj["compression"])
            if obj.get("compression") is not None
            else None,
            "directivity": Directivity.from_dict(obj["directivity"])
            if obj.get("directivity") is not None
            else None,
            "fader": Fader.from_dict(obj["fader"])
            if obj.get("fader") is not None
            else None,
            "roomCompensation": RoomCompensation.from_dict(obj["roomCompensation"])
            if obj.get("roomCompensation") is not None
            else None,
            "spatialEnvelopment": SpatialEnvelopment.from_dict(
                obj["spatialEnvelopment"]
            )
            if obj.get("spatialEnvelopment") is not None
            else None,
            "spatialHeight": SpatialHeight.from_dict(obj["spatialHeight"])
            if obj.get("spatialHeight") is not None
            else None,
            "spatialProcessing": SpatialProcessing.from_dict(obj["spatialProcessing"])
            if obj.get("spatialProcessing") is not None
            else None,
            "spatialSurround": SpatialSurround.from_dict(obj["spatialSurround"])
            if obj.get("spatialSurround") is not None
            else None,
            "spatialWidth": SpatialWidth.from_dict(obj["spatialWidth"])
            if obj.get("spatialWidth") is not None
            else None,
            "speechEnhance": SpeechEnhance.from_dict(obj["speechEnhance"])
            if obj.get("speechEnhance") is not None
            else None,
            "toneTouch": ToneTouch.from_dict(obj["toneTouch"])
            if obj.get("toneTouch") is not None
            else None,
        })
        return _obj
