def deserialize(api_data): # type: (Dict[str,Any]) -> VentilationStatusDTO status_dto = VentilationStatusDTO(id=api_data['id'], mode=api_data['mode']) if 'level' in api_data: status_dto.level = Toolbox.nonify(api_data['level'], 0) if 'timer' in api_data: status_dto.timer = Toolbox.nonify(api_data['timer'], 0) if 'remaining_time' in api_data: status_dto.remaining_time = Toolbox.nonify( api_data['remaining_time'], 0) return status_dto
def deserialize(api_data): # type: (Dict[str,Any]) -> Tuple[VentilationStatusDTO, List[str]] loaded_fields = ['id', 'mode'] status_dto = VentilationStatusDTO(api_data['id'], api_data['mode']) if 'level' in api_data: loaded_fields.append('level') status_dto.level = Toolbox.nonify(api_data['level'], 0) if 'timer' in api_data: loaded_fields.append('timer') status_dto.timer = Toolbox.nonify(api_data['timer'], 0) if 'remaining_time' in api_data: loaded_fields.append('remaining_time') status_dto.remaining_time = Toolbox.nonify( api_data['remaining_time'], 0) return status_dto, loaded_fields