# 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 pprint
import re  # noqa: F401
import json


from typing import Optional

try:
    from pydantic.v1 import BaseModel, Field
except ImportError:
    from pydantic import BaseModel, Field

from mozart_api.models.microphones_state import MicrophonesState
from mozart_api.models.playback_state import PlaybackState
from mozart_api.models.power_state_enum import PowerStateEnum
from mozart_api.models.software_update_state import SoftwareUpdateState
from mozart_api.models.sound_settings import SoundSettings
from mozart_api.models.source import Source
from mozart_api.models.tv_state import TvState
from mozart_api.models.volume_state import VolumeState


class ProductState(BaseModel):
    """
    ProductState
    """

    microphones: Optional[MicrophonesState] = None
    playback: Optional[PlaybackState] = None
    power_state: Optional[PowerStateEnum] = Field(default=None, alias="powerState")
    software_update_state: Optional[SoftwareUpdateState] = Field(
        default=None, alias="softwareUpdateState"
    )
    sound_settings: Optional[SoundSettings] = Field(default=None, alias="soundSettings")
    source: Optional[Source] = None
    tv: Optional[TvState] = None
    volume: Optional[VolumeState] = None
    __properties = [
        "microphones",
        "playback",
        "powerState",
        "softwareUpdateState",
        "soundSettings",
        "source",
        "tv",
        "volume",
    ]

    class Config:
        """Pydantic configuration"""

        allow_population_by_field_name = True
        validate_assignment = True

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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

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

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True, exclude={}, exclude_none=True)
        # override the default output from pydantic by calling `to_dict()` of microphones
        if self.microphones:
            _dict["microphones"] = self.microphones.to_dict()
        # override the default output from pydantic by calling `to_dict()` of playback
        if self.playback:
            _dict["playback"] = self.playback.to_dict()
        # override the default output from pydantic by calling `to_dict()` of power_state
        if self.power_state:
            _dict["powerState"] = self.power_state.to_dict()
        # override the default output from pydantic by calling `to_dict()` of software_update_state
        if self.software_update_state:
            _dict["softwareUpdateState"] = self.software_update_state.to_dict()
        # override the default output from pydantic by calling `to_dict()` of sound_settings
        if self.sound_settings:
            _dict["soundSettings"] = self.sound_settings.to_dict()
        # override the default output from pydantic by calling `to_dict()` of source
        if self.source:
            _dict["source"] = self.source.to_dict()
        # override the default output from pydantic by calling `to_dict()` of tv
        if self.tv:
            _dict["tv"] = self.tv.to_dict()
        # override the default output from pydantic by calling `to_dict()` of volume
        if self.volume:
            _dict["volume"] = self.volume.to_dict()
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> ProductState:
        """Create an instance of ProductState from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return ProductState.parse_obj(obj)

        _obj = ProductState.parse_obj(
            {
                "microphones": (
                    MicrophonesState.from_dict(obj.get("microphones"))
                    if obj.get("microphones") is not None
                    else None
                ),
                "playback": (
                    PlaybackState.from_dict(obj.get("playback"))
                    if obj.get("playback") is not None
                    else None
                ),
                "power_state": (
                    PowerStateEnum.from_dict(obj.get("powerState"))
                    if obj.get("powerState") is not None
                    else None
                ),
                "software_update_state": (
                    SoftwareUpdateState.from_dict(obj.get("softwareUpdateState"))
                    if obj.get("softwareUpdateState") is not None
                    else None
                ),
                "sound_settings": (
                    SoundSettings.from_dict(obj.get("soundSettings"))
                    if obj.get("soundSettings") is not None
                    else None
                ),
                "source": (
                    Source.from_dict(obj.get("source"))
                    if obj.get("source") is not None
                    else None
                ),
                "tv": (
                    TvState.from_dict(obj.get("tv"))
                    if obj.get("tv") is not None
                    else None
                ),
                "volume": (
                    VolumeState.from_dict(obj.get("volume"))
                    if obj.get("volume") is not None
                    else None
                ),
            }
        )
        return _obj
