mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 19:34:54 +00:00
Updated the API Endpoints, API Calls, Data Models and cubits to the lateset changes from the backend
This commit is contained in:
@ -5,25 +5,14 @@ import 'package:syncrow_app/utils/resource_manager/constants.dart';
|
||||
|
||||
class DeviceModel {
|
||||
int? activeTime;
|
||||
String? category; //unused
|
||||
String? categoryName; //unused
|
||||
int? createTime; //unused
|
||||
String? gatewayId; //unused
|
||||
String? icon; //unused
|
||||
String? id;
|
||||
String? ip; //unused
|
||||
double? lat; //unused
|
||||
// String? id;
|
||||
String? localKey;
|
||||
double? lon; //unused
|
||||
String? model;
|
||||
String? name;
|
||||
String? nodeId; //remove
|
||||
String? icon;
|
||||
bool? isOnline;
|
||||
List<StatusModel> status = [];
|
||||
String? ownerId; //unused
|
||||
String? productId; //unused
|
||||
String? productName;
|
||||
bool? isSub; //unused
|
||||
String? timeZone;
|
||||
int? updateTime;
|
||||
String? uuid;
|
||||
@ -32,108 +21,70 @@ class DeviceModel {
|
||||
late List<FunctionModel> functions;
|
||||
DeviceModel({
|
||||
this.activeTime,
|
||||
this.category,
|
||||
this.categoryName,
|
||||
this.createTime,
|
||||
this.gatewayId,
|
||||
this.icon,
|
||||
this.id,
|
||||
this.ip,
|
||||
this.lat,
|
||||
// this.id,
|
||||
this.localKey,
|
||||
this.lon,
|
||||
this.model,
|
||||
this.name,
|
||||
this.nodeId,
|
||||
this.isOnline,
|
||||
required this.status,
|
||||
this.ownerId,
|
||||
this.productId,
|
||||
this.productName,
|
||||
this.isSub,
|
||||
this.timeZone,
|
||||
this.updateTime,
|
||||
this.uuid,
|
||||
this.productType,
|
||||
this.icon,
|
||||
}) {
|
||||
functions = getFunctions(productType!);
|
||||
}
|
||||
|
||||
factory DeviceModel.fromJson(Map<String, dynamic> json) {
|
||||
String icon = '';
|
||||
DeviceType type = devicesTypesMap[json['productId']] ?? DeviceType.Other;
|
||||
String tempIcon = '';
|
||||
DeviceType type = devicesTypesMap[json['productType']] ?? DeviceType.Other;
|
||||
|
||||
if (type == DeviceType.LightBulb) {
|
||||
icon = Assets.iconsLight;
|
||||
tempIcon = Assets.iconsLight;
|
||||
} else if (type == DeviceType.CeilingSensor ||
|
||||
type == DeviceType.WallSensor) {
|
||||
icon = Assets.iconsSensors;
|
||||
tempIcon = Assets.iconsSensors;
|
||||
} else if (type == DeviceType.AC) {
|
||||
icon = Assets.iconsAC;
|
||||
tempIcon = Assets.iconsAC;
|
||||
} else if (type == DeviceType.DoorLock) {
|
||||
icon = Assets.iconsDoorLock;
|
||||
tempIcon = Assets.iconsDoorLock;
|
||||
} else if (type == DeviceType.Curtain) {
|
||||
icon = Assets.iconsCurtain;
|
||||
tempIcon = Assets.iconsCurtain;
|
||||
} else if (type == DeviceType.ThreeGang) {
|
||||
icon = Assets.icons3GangSwitch;
|
||||
tempIcon = Assets.icons3GangSwitch;
|
||||
} else if (type == DeviceType.Gateway) {
|
||||
icon = Assets.iconsGateway;
|
||||
tempIcon = Assets.iconsGateway;
|
||||
} else {
|
||||
icon = Assets.iconsLogo;
|
||||
tempIcon = Assets.iconsLogo;
|
||||
}
|
||||
return DeviceModel(
|
||||
icon: tempIcon,
|
||||
activeTime: json['activeTime'],
|
||||
category: json['category'],
|
||||
categoryName: json['categoryName'],
|
||||
createTime: json['createTime'],
|
||||
gatewayId: json['gatewayId'],
|
||||
icon: icon,
|
||||
id: json['id'],
|
||||
ip: json['ip'],
|
||||
lat: double.tryParse(json['lat']),
|
||||
// id: json['id'],
|
||||
localKey: json['localKey'],
|
||||
lon: double.tryParse(json['lon']),
|
||||
model: json['model'],
|
||||
name: json['name'],
|
||||
nodeId: json['nodeId'],
|
||||
isOnline: json['online'],
|
||||
ownerId: json['ownerId'],
|
||||
productId: json['productId'],
|
||||
productName: json['productName'],
|
||||
isSub: json['sub'],
|
||||
timeZone: json['timeZone'],
|
||||
updateTime: json['updateTime'],
|
||||
uuid: json['uuid'],
|
||||
productType: type,
|
||||
status: [],
|
||||
// json['status']
|
||||
// .map<StatusModel>((e) => StatusModel.fromJson(e))
|
||||
// .toList(),
|
||||
// devicesTypesMap[json['productName']] ?? DeviceType.Other,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'activeTime': activeTime,
|
||||
'category': category,
|
||||
'categoryName': categoryName,
|
||||
'createTime': createTime,
|
||||
'gatewayId': gatewayId,
|
||||
'icon': icon,
|
||||
'id': id,
|
||||
'ip': ip,
|
||||
'lat': lat,
|
||||
// 'id': id,
|
||||
'localKey': localKey,
|
||||
'lon': lon,
|
||||
'model': model,
|
||||
'name': name,
|
||||
'nodeId': nodeId,
|
||||
'online': isOnline,
|
||||
'ownerId': ownerId,
|
||||
'productId': productId,
|
||||
'productName': productName,
|
||||
'sub': isSub,
|
||||
'timeZone': timeZone,
|
||||
'updateTime': updateTime,
|
||||
'uuid': uuid,
|
||||
|
||||
Reference in New Issue
Block a user