addressing feedback on from_api_response

This commit is contained in:
Khalim Conn-Kowlessar 2026-04-28 12:02:34 +00:00
parent 8ec6eecc4d
commit 821a0a08f7

View file

@ -1,5 +1,5 @@
from datetime import date
from typing import List, Optional, Sequence, Union
from typing import List, Optional, Sequence, Union, Dict, Any
from datatypes.epc.domain.epc_property_data import (
EnergyElement,
@ -1448,7 +1448,7 @@ class EpcPropertyDataMapper:
return [EpcPropertyDataMapper._map_energy_element(e) for e in elements]
@staticmethod
def from_api_response(data: dict) -> "EpcPropertyData":
def from_api_response(data: Dict[str, Any]) -> "EpcPropertyData":
"""
Dispatch to the correct schema mapper based on schema_type.
Supports RdSAP-Schema-21.0.0 and RdSAP-Schema-21.0.1 only.
@ -1459,11 +1459,13 @@ class EpcPropertyDataMapper:
schema = data.get("schema_type", "")
if schema == "RdSAP-Schema-21.0.1":
from datatypes.epc.schema.rdsap_schema_21_0_1 import RdSapSchema21_0_1
return EpcPropertyDataMapper.from_rdsap_schema_21_0_1(
from_dict(RdSapSchema21_0_1, data)
)
if schema == "RdSAP-Schema-21.0.0":
from datatypes.epc.schema.rdsap_schema_21_0_0 import RdSapSchema21_0_0
return EpcPropertyDataMapper.from_rdsap_schema_21_0_0(
from_dict(RdSapSchema21_0_0, data)
)
@ -1596,7 +1598,11 @@ def _map_sap_heating(
fuel_type = (
_raw_fuel
if _raw_fuel
else ("Electricity" if main.system_type.lower() in _ELECTRIC_SYSTEM_TYPES else _raw_fuel)
else (
"Electricity"
if main.system_type.lower() in _ELECTRIC_SYSTEM_TYPES
else _raw_fuel
)
)
return SapHeating(
@ -1618,7 +1624,11 @@ def _map_sap_heating(
secondary_fuel_type=secondary_fuel_type,
secondary_heating_type=heating.secondary_heating.secondary_system,
shower_outlets=shower_outlets,
cylinder_size=heating.water_heating.cylinder_size if heating.water_heating.cylinder_size != "No Cylinder" else None,
cylinder_size=(
heating.water_heating.cylinder_size
if heating.water_heating.cylinder_size != "No Cylinder"
else None
),
cylinder_insulation_type=heating.water_heating.insulation_type,
cylinder_insulation_thickness_mm=heating.water_heating.insulation_thickness_mm,
immersion_heating_type=heating.water_heating.immersion_type,