SmartScene.fromJson constructor
Creates a SmartScene object from the JSON response to a GET request.
Implementation
factory SmartScene.fromJson(Map<String, dynamic> dataMap) {
// Handle entire response given with no filter.
Map<String, dynamic> data = MiscTools.extractData(dataMap);
return SmartScene(
type: ResourceType.fromString(data[ApiFields.type] ?? ""),
id: data[ApiFields.id] ?? "",
idV1: data[ApiFields.idV1] ?? "",
metadata: SmartSceneMetadata.fromJson(
Map<String, dynamic>.from(data[ApiFields.metadata] ?? {})),
group: Relative.fromJson(
Map<String, dynamic>.from(data[ApiFields.group] ?? {})),
weekTimeslots: (data[ApiFields.weekTimeslots] as List<dynamic>?)
?.map((weekTimeslotMap) => SmartSceneWeek.fromJson(
Map<String, dynamic>.from(weekTimeslotMap)))
.toList() ??
[],
activeTimeslot: SmartSceneActiveTimeslot.fromJson(
Map<String, dynamic>.from(data[ApiFields.activeTimeslot] ?? {})),
state: data[ApiFields.state] ?? "",
recallAction: Map<String, dynamic>.from(
data[ApiFields.recall] ?? {})[ApiFields.action]);
}