Added gateway screen and bloc

This commit is contained in:
Abdullah Alassaf
2024-06-25 02:21:35 +03:00
parent bc3cd66096
commit f98ebdb2ba
13 changed files with 296 additions and 47 deletions

View File

@ -50,7 +50,6 @@ class DevicesAPI {
}
static Future<List<DeviceModel>> getDevicesByRoomId(String roomId) async {
// print("Room ID: $roomId");
final response = await _httpService.get(
path: ApiEndpoints.deviceByRoom,
queryParameters: {"roomUuid": roomId},
@ -68,4 +67,22 @@ class DevicesAPI {
);
return response;
}
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
final response = await _httpService.get(
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
showServerMessage: false,
expectedResponseModel: (json) {
List<DeviceModel> devices = [];
if (json == null || json.isEmpty || json == []) {
return devices;
}
for (var device in json['devices']) {
devices.add(DeviceModel.fromJson(device));
}
return devices;
},
);
return response;
}
}