Fetched devices based on the unit id

This commit is contained in:
Abdullah Alassaf
2024-07-01 22:27:15 +03:00
parent 4b6d82812d
commit ce94d91f83
5 changed files with 47 additions and 49 deletions

View File

@ -1,4 +1,5 @@
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart';
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
@ -23,6 +24,20 @@ class HomeManagementAPI {
return list;
}
static Future<List<DeviceModel>> fetchDevicesByUnitId() async {
List<DeviceModel> list = [];
await _httpService.get(
path: ApiEndpoints.getDevicesByUnitId
.replaceAll("{unitUuid}", HomeCubit.getInstance().selectedSpace?.id ?? ''),
showServerMessage: false,
expectedResponseModel: (json) {
json.forEach((value) {
list.add(DeviceModel.fromJson(value));
});
});
return list;
}
static Future<Map<String, dynamic>> assignDeviceToRoom(Map<String, String> body) async {
try {
final response = await _httpService.put(