ZigbeeDeviceDiscovery.fromJson constructor
Creates a ZigbeeDeviceDiscovery object from the JSON response to a GET request.
Implementation
factory ZigbeeDeviceDiscovery.fromJson(Map<String, dynamic> dataMap) {
// Handle entire response given with no filter.
Map<String, dynamic> data = MiscTools.extractData(dataMap);
return ZigbeeDeviceDiscovery(
type: ResourceType.fromString(data[ApiFields.type] ?? ""),
id: data[ApiFields.id] ?? "",
idV1: data[ApiFields.idV1] ?? "",
owner: Relative.fromJson(
Map<String, dynamic>.from(data[ApiFields.owner] ?? {})),
status: data[ApiFields.status] ?? "",
action: data[ApiFields.action] == null
? null
: ZigbeeDeviceDiscoveryAction.fromJson(
Map<String, dynamic>.from(data[ApiFields.action])),
);
}