Terminal.fromJson constructor
Terminal.fromJson(
- Map<String, dynamic> json
)
Implementation
factory Terminal.fromJson(Map<String, dynamic> json) {
return Terminal(
id: json['_id'] ?? '',
deviceId: json['deviceId'] ?? '',
name: json['name'] ?? '',
displayName: json['displayName'] ?? '',
description: json['description'] ?? '',
device: DeviceInfo.fromJson(json['device'] ?? {}),
app: AppInfo.fromJson(json['app'] ?? {}),
userId: json['userId'] ?? '',
businessId: json['businessId'] ?? '',
merchantId: json['merchantId'] ?? '',
cardEnabled: json['card_enabled'] ?? false,
deleted: json['deleted'] ?? false,
status: json['status'] ?? '',
serialNumber: json['serialNumber'] ?? '',
terminalId: json['terminalId'] ?? '',
family: json['family'] ?? '',
platform: json['platform'] ?? '',
product: json['product'] ?? '',
type: json['type'] ?? '',
version: json['version'] ?? '',
board: json['board'] ?? '',
bootLoader: json['bootLoader'] ?? '',
brand: json['brand'] ?? '',
isPhysicalDevice: json['isPhysicalDevice'] ?? false,
deviceType: json.containsKey('deviceType')
? DeviceType.values.firstWhere(
(e) => e.toString() == json['deviceType'],
orElse: () => DeviceType.unknown,
)
: DeviceType.unknown,
display: json['display'] ?? '',
fingerprint: json['fingerprint'] ?? '',
hardware: json['hardware'] ?? '',
host: json['host'] ?? '',
model: json['model'] ?? '',
dateCreated: DateTime.parse(
json['dateCreated'] ?? DateTime.now().toIso8601String()),
dateUpdated: json['dateUpdated'] != null
? DateTime.parse(json['dateUpdated'])
: null,
createdBy: json['createdBy'] ?? '',
updatedBy: json['updatedBy'] ?? '',
);
}