You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/modules/asset_tracking/models/asset_tracking_model.dart

224 lines
6.1 KiB
Dart

import 'package:test_sa/models/base.dart';
class AssetTrackingModel extends Base {
int? id;
String? label;
String? serialNumber;
int? group;
Type? type;
Type? department;
Type? status;
Location? location;
Tag? tag;
Alerts? alerts;
AssetTrackingModel({this.id, this.label, this.serialNumber, this.group, this.type, this.department, this.status, this.location, this.tag, this.alerts})
: super(identifier: id?.toString(), name: label);
AssetTrackingModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
identifier = json['id']?.toString();
label = json['label'];
serialNumber = json['serialNumber'];
name = "$label ($serialNumber)";
group = json['group'];
type = json['type'] != null ? new Type.fromJson(json['type']) : null;
department = json['department'] != null ? new Type.fromJson(json['department']) : null;
status = json['status'] != null ? new Type.fromJson(json['status']) : null;
location = json['location'] != null ? new Location.fromJson(json['location']) : null;
tag = json['tag'] != null ? new Tag.fromJson(json['tag']) : null;
alerts = json['alerts'] != null ? new Alerts.fromJson(json['alerts']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['label'] = this.label;
data['serialNumber'] = this.serialNumber;
data['group'] = this.group;
if (this.type != null) {
data['type'] = this.type!.toJson();
}
if (this.department != null) {
data['department'] = this.department!.toJson();
}
if (this.status != null) {
data['status'] = this.status!.toJson();
}
if (this.location != null) {
data['location'] = this.location!.toJson();
}
if (this.tag != null) {
data['tag'] = this.tag!.toJson();
}
if (this.alerts != null) {
data['alerts'] = this.alerts!.toJson();
}
return data;
}
}
class Type {
int? id;
String? name;
Type({this.id, this.name});
Type.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
return data;
}
}
class Location {
bool? isLive;
String? lastSeen;
Type? venue;
Floor? floor;
Zone? zone;
double? longitude;
double? latitude;
double? x;
double? y;
Location({this.isLive, this.lastSeen, this.venue, this.floor, this.zone, this.longitude, this.latitude, this.x, this.y});
Location.fromJson(Map<String, dynamic> json) {
isLive = json['isLive'];
lastSeen = json['lastSeen'];
venue = json['venue'] != null ? new Type.fromJson(json['venue']) : null;
floor = json['floor'] != null ? new Floor.fromJson(json['floor']) : null;
zone = json['zone'] != null ? new Zone.fromJson(json['zone']) : null;
longitude = json['longitude'];
latitude = json['latitude'];
x = json['x'];
y = json['y'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['isLive'] = this.isLive;
data['lastSeen'] = this.lastSeen;
if (this.venue != null) {
data['venue'] = this.venue!.toJson();
}
if (this.floor != null) {
data['floor'] = this.floor!.toJson();
}
if (this.zone != null) {
data['zone'] = this.zone!.toJson();
}
data['longitude'] = this.longitude;
data['latitude'] = this.latitude;
data['x'] = this.x;
data['y'] = this.y;
return data;
}
}
class Floor {
int? id;
String? name;
String? label;
Floor({this.id, this.name, this.label});
Floor.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
label = json['label'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
data['label'] = this.label;
return data;
}
}
class Zone {
int? id;
String? name;
Type? zoneType;
Zone({this.id, this.name, this.zoneType});
Zone.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
zoneType = json['zoneType'] != null ? new Type.fromJson(json['zoneType']) : null;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['name'] = this.name;
if (this.zoneType != null) {
data['zoneType'] = this.zoneType!.toJson();
}
return data;
}
}
class Tag {
int? id;
String? macAddress;
int? batteryPercentage;
Tag({this.id, this.macAddress, this.batteryPercentage});
Tag.fromJson(Map<String, dynamic> json) {
id = json['id'];
macAddress = json['macAddress'];
batteryPercentage = json['batteryPercentage'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['macAddress'] = this.macAddress;
data['batteryPercentage'] = this.batteryPercentage;
return data;
}
}
class Alerts {
int? count;
String? lastCreationDate;
String? mostSevereCreationDate;
String? mostSevereTriggerType;
String? mostSeverity;
String? mostSevereRuleName;
Alerts({this.count, this.lastCreationDate, this.mostSevereCreationDate, this.mostSevereTriggerType, this.mostSeverity, this.mostSevereRuleName});
Alerts.fromJson(Map<String, dynamic> json) {
count = json['count'];
lastCreationDate = json['lastCreationDate'];
mostSevereCreationDate = json['mostSevereCreationDate'];
mostSevereTriggerType = json['mostSevereTriggerType'];
mostSeverity = json['mostSeverity'];
mostSevereRuleName = json['mostSevereRuleName'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['count'] = this.count;
data['lastCreationDate'] = this.lastCreationDate;
data['mostSevereCreationDate'] = this.mostSevereCreationDate;
data['mostSevereTriggerType'] = this.mostSevereTriggerType;
data['mostSeverity'] = this.mostSeverity;
data['mostSevereRuleName'] = this.mostSevereRuleName;
return data;
}
}