# coding: utf-8

"""
    Weheat Backend

    This is the backend for the Weheat project

    The version of the OpenAPI document: v1
    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 datetime import datetime
from typing import Optional
from pydantic import BaseModel, Field, StrictStr, constr
from weheat.models.boiler_type import BoilerType
from weheat.models.device_state import DeviceState
from weheat.models.dhw_type import DhwType
from weheat.models.heat_pump_model import HeatPumpModel
from weheat.models.heat_pump_status_enum import HeatPumpStatusEnum
from weheat.models.heat_pump_type import HeatPumpType

class ReadAllHeatPumpDto(BaseModel):
    """
    Heat Pump dto used for the GetAll operation where the firmware version is needed  # noqa: E501
    """
    id: StrictStr = Field(..., description="Identifier of the heat pump")
    control_board_id: StrictStr = Field(..., alias="controlBoardId", description="Identifier of the control board that is connected to the heat pump")
    serial_number: constr(strict=True, min_length=1) = Field(..., alias="serialNumber", description="Serial Number of this heat pump")
    part_number: Optional[StrictStr] = Field(None, alias="partNumber", description="Part Number of this heat pump")
    state: DeviceState = Field(...)
    name: Optional[StrictStr] = Field(None, description="Internal nickname of this heat pump")
    model: Optional[HeatPumpModel] = None
    dhw_type: Optional[DhwType] = Field(None, alias="dhwType")
    boiler_type: Optional[BoilerType] = Field(None, alias="boilerType")
    status: Optional[HeatPumpStatusEnum] = None
    type: Optional[HeatPumpType] = None
    commissioned_at: Optional[datetime] = Field(None, alias="commissionedAt", description="Date when the heat pump was last commissioned (decommissioning sets this to null)")
    firmware_version: Optional[StrictStr] = Field(None, alias="firmwareVersion", description="Firmware version of control board connected to heat pump")
    __properties = ["id", "controlBoardId", "serialNumber", "partNumber", "state", "name", "model", "dhwType", "boilerType", "status", "type", "commissionedAt", "firmwareVersion"]

    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) -> ReadAllHeatPumpDto:
        """Create an instance of ReadAllHeatPumpDto 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)
        # set to None if part_number (nullable) is None
        # and __fields_set__ contains the field
        if self.part_number is None and "part_number" in self.__fields_set__:
            _dict['partNumber'] = None

        # set to None if name (nullable) is None
        # and __fields_set__ contains the field
        if self.name is None and "name" in self.__fields_set__:
            _dict['name'] = None

        # set to None if commissioned_at (nullable) is None
        # and __fields_set__ contains the field
        if self.commissioned_at is None and "commissioned_at" in self.__fields_set__:
            _dict['commissionedAt'] = None

        # set to None if firmware_version (nullable) is None
        # and __fields_set__ contains the field
        if self.firmware_version is None and "firmware_version" in self.__fields_set__:
            _dict['firmwareVersion'] = None

        return _dict

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

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

        _obj = ReadAllHeatPumpDto.parse_obj({
            "id": obj.get("id"),
            "control_board_id": obj.get("controlBoardId"),
            "serial_number": obj.get("serialNumber"),
            "part_number": obj.get("partNumber"),
            "state": obj.get("state"),
            "name": obj.get("name"),
            "model": obj.get("model"),
            "dhw_type": obj.get("dhwType"),
            "boiler_type": obj.get("boilerType"),
            "status": obj.get("status"),
            "type": obj.get("type"),
            "commissioned_at": obj.get("commissionedAt"),
            "firmware_version": obj.get("firmwareVersion")
        })
        return _obj


