# 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 Any, ClassVar, Dict, List, Optional
from pydantic import BaseModel, StrictStr
from pydantic import Field
from typing_extensions import Annotated
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
try:
    from typing import Self
except ImportError:
    from typing_extensions import Self

class ReadHeatPumpDto(BaseModel):
    """
    ReadHeatPumpDto
    """ # noqa: E501
    control_board_id: StrictStr = Field(description="Identifier of the control board that is connected to the heat pump", alias="controlBoardId")
    name: Optional[StrictStr] = Field(default=None, description="Internal nickname of this heat pump")
    model: Optional[HeatPumpModel] = None
    dhw_type: Optional[DhwType] = Field(default=None, alias="dhwType")
    boiler_type: Optional[BoilerType] = Field(default=None, alias="boilerType")
    status: Optional[HeatPumpStatusEnum] = None
    commissioned_at: Optional[datetime] = Field(default=None, description="Date when the heat pump was last commissioned (decommissioning sets this to null)", alias="commissionedAt")
    serial_number: Annotated[str, Field(min_length=1, strict=True)] = Field(description="Serial Number of this heat pump", alias="serialNumber")
    part_number: Optional[StrictStr] = Field(default=None, description="Part Number of this heat pump", alias="partNumber")
    state: DeviceState
    id: StrictStr = Field(description="Identifier of the heat pump")
    __properties: ClassVar[List[str]] = ["controlBoardId", "name", "model", "dhwType", "boilerType", "status", "commissionedAt", "serialNumber", "partNumber", "state", "id"]

    model_config = {
        "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) -> Self:
        """Create an instance of ReadHeatPumpDto 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.
        """
        _dict = self.model_dump(
            by_alias=True,
            exclude={
            },
            exclude_none=True,
        )
        # set to None if name (nullable) is None
        # and model_fields_set contains the field
        if self.name is None and "name" in self.model_fields_set:
            _dict['name'] = None

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

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

        return _dict

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

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

        _obj = cls.model_validate({
            "controlBoardId": obj.get("controlBoardId"),
            "name": obj.get("name"),
            "model": obj.get("model"),
            "dhwType": obj.get("dhwType"),
            "boilerType": obj.get("boilerType"),
            "status": obj.get("status"),
            "commissionedAt": obj.get("commissionedAt"),
            "serialNumber": obj.get("serialNumber"),
            "partNumber": obj.get("partNumber"),
            "state": obj.get("state"),
            "id": obj.get("id")
        })
        return _obj


