Implemented devices groups

This commit is contained in:
Abdullah Alassaf
2024-06-26 22:30:56 +03:00
parent 1fb8a8d035
commit 61c225af45
34 changed files with 1257 additions and 738 deletions

View File

@ -27,13 +27,13 @@ class DevicesAPI {
}
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
Map<String, dynamic> params = {"homeId": spaceId, "pageSize": 100, "pageNo": 1};
// Map<String, dynamic> params = {"homeId": spaceId, "pageSize": 100, "pageNo": 1};
final response = await _httpService.get(
path: ApiEndpoints.groupBySpace.replaceAll("{spaceUuid}", spaceId),
queryParameters: params,
path: ApiEndpoints.groupBySpace.replaceAll('{unitUuid}', spaceId),
// queryParameters: params,
showServerMessage: false,
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json['groups']),
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json),
);
return response;
}
@ -49,6 +49,26 @@ class DevicesAPI {
return response;
}
static Future<List<DeviceModel>> getDeviceByGroupName(String unitId, String groupName) async {
final response = await _httpService.get(
path: ApiEndpoints.devicesByGroupName
.replaceAll('{unitUuid}', unitId)
.replaceAll('{groupName}', groupName),
showServerMessage: false,
expectedResponseModel: (json) {
if (json == null || json.isEmpty || json == []) {
return <DeviceModel>[];
}
List<DeviceModel> devices = [];
for (var device in json) {
devices.add(DeviceModel.fromJson(device));
}
return devices;
},
);
return response;
}
static Future<List<DeviceModel>> getDevicesByRoomId(String roomId) async {
final response = await _httpService.get(
path: ApiEndpoints.deviceByRoom,