mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
updated endpoints
This commit is contained in:
@ -24,7 +24,7 @@ class DevicesManagementApi {
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData =
|
||||
communityId.isNotEmpty && spaceId.isNotEmpty ? json['data'] : json;
|
||||
communityId.isNotEmpty && spaceId.isNotEmpty ? json['data'] : json['data'];
|
||||
List<AllDevicesModel> devicesList = jsonData.map((jsonItem) {
|
||||
return AllDevicesModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -33,7 +33,7 @@ class DevicesManagementApi {
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching $e');
|
||||
debugPrint('Error fetching device $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ class DevicesManagementApi {
|
||||
path: ApiEndpoints.getDeviceStatus.replaceAll('{uuid}', uuid),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json);
|
||||
return DeviceStatus.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -61,7 +61,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;
|
||||
@ -98,6 +98,7 @@ class DevicesManagementApi {
|
||||
'devicesUuid': uuids,
|
||||
'code': code,
|
||||
'value': value,
|
||||
'operationType': 'COMMAND',
|
||||
};
|
||||
|
||||
final response = await HTTPService().post(
|
||||
@ -105,7 +106,7 @@ class DevicesManagementApi {
|
||||
body: body,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return (json['successResults'] as List).isNotEmpty;
|
||||
return json['success'] ?? false;
|
||||
},
|
||||
);
|
||||
|
||||
@ -125,7 +126,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;
|
||||
@ -153,7 +154,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;
|
||||
@ -169,7 +170,7 @@ class DevicesManagementApi {
|
||||
.replaceAll('{endTime}', to ?? ''),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceReport.fromJson(json);
|
||||
return DeviceReport.fromJson(json['data']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
@ -185,7 +186,7 @@ class DevicesManagementApi {
|
||||
queryParameters: queryParameters,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return DeviceStatus.fromJson(json['status']);
|
||||
return DeviceStatus.fromJson(json['data']['status']);
|
||||
},
|
||||
);
|
||||
return response;
|
||||
|
Reference in New Issue
Block a user