Merged with dev

This commit is contained in:
Abdullah Alassaf
2025-04-06 01:17:30 +03:00
13 changed files with 481 additions and 319 deletions

View File

@ -32,7 +32,7 @@ class DevicesManagementApi {
);
return response;
} catch (e) {
debugPrint('fetchDevices Error fetching $e');
debugPrint('Error fetching device $e');
return [];
}
}
@ -43,7 +43,7 @@ class DevicesManagementApi {
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid),
showServerMessage: true,
expectedResponseModel: (json) {
return DeviceStatus.fromJson(json);
return DeviceStatus.fromJson(json['data']);
},
);
return response;
@ -60,7 +60,7 @@ class DevicesManagementApi {
Future getPowerClampInfo(String deviceId) async {
try {
final response = await HTTPService().get(
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', deviceId),
showServerMessage: true,
expectedResponseModel: (json) {
return json;
@ -97,6 +97,7 @@ class DevicesManagementApi {
'devicesUuid': uuids,
'code': code,
'value': value,
'operationType': 'COMMAND',
};
final response = await HTTPService().post(
@ -104,7 +105,7 @@ class DevicesManagementApi {
body: body,
showServerMessage: true,
expectedResponseModel: (json) {
return (json['successResults'] as List).isNotEmpty;
return json['success'] ?? false;
},
);
@ -124,7 +125,7 @@ class DevicesManagementApi {
if (json == null || json.isEmpty || json == []) {
return devices;
}
for (var device in json['devices']) {
for (var device in json['data']['devices']) {
devices.add(DeviceModel.fromJson(device));
}
return devices;
@ -152,7 +153,7 @@ class DevicesManagementApi {
path: ApiEndpoints.getDeviceLogs.replaceAll('{uuid}', uuid).replaceAll('{code}', code),
showServerMessage: false,
expectedResponseModel: (json) {
return DeviceReport.fromJson(json);
return DeviceReport.fromJson(json['data']);
},
);
return response;
@ -168,7 +169,7 @@ class DevicesManagementApi {
.replaceAll('{endTime}', to ?? ''),
showServerMessage: false,
expectedResponseModel: (json) {
return DeviceReport.fromJson(json);
return DeviceReport.fromJson(json['data']);
},
);
return response;
@ -184,7 +185,7 @@ class DevicesManagementApi {
queryParameters: queryParameters,
showServerMessage: true,
expectedResponseModel: (json) {
return DeviceStatus.fromJson(json['status']);
return DeviceStatus.fromJson(json['data']['status']);
},
);
return response;