BridgeHome.fromJson constructor
Creates a BridgeHome object from the JSON response to a GET request.
Implementation
factory BridgeHome.fromJson(Map<String, dynamic> dataMap) {
// Handle entire response given with no filter.
Map<String, dynamic> data = MiscTools.extractData(dataMap);
return BridgeHome(
type: ResourceType.fromString(data[ApiFields.type] ?? ""),
id: data[ApiFields.id] ?? "",
idV1: data[ApiFields.idV1] ?? "",
children: (data[ApiFields.children] as List<dynamic>?)
?.map((child) => Relative.fromJson(child))
.toList() ??
[],
services: (data[ApiFields.services] as List<dynamic>?)
?.map((service) => Relative.fromJson(service))
.toList() ??
[],
);
}