mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Refactor code by adding new API endpoint for assigning a device to a room and removing redundant code in device management settings.
This commit is contained in:
@ -386,4 +386,6 @@ class DevicesManagementApi {
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/device_setting/bloc/sub_space_model.dart';
|
||||
import 'package:syncrow_web/pages/device_managment/device_setting/settings_model/sub_space_model.dart';
|
||||
import 'package:syncrow_web/pages/space_tree/model/pagination_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
|
||||
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/create_subspace_model.dart';
|
||||
@ -369,7 +369,9 @@ class CommunitySpaceManagementApi {
|
||||
}
|
||||
|
||||
static Future<List<SubSpaceModel>> getSubSpaceBySpaceId(
|
||||
String communityId, String spaceId, String projectId) async {
|
||||
{required String communityId,
|
||||
required String spaceId,
|
||||
required String projectId}) async {
|
||||
try {
|
||||
// Construct the API path
|
||||
final path = ApiEndpoints.listSubspace
|
||||
@ -399,4 +401,29 @@ class CommunitySpaceManagementApi {
|
||||
return []; // Return an empty list if there's an error
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> assignDeviceToRoom(
|
||||
{required String communityId,
|
||||
required String spaceId,
|
||||
required String subSpaceId,
|
||||
required String deviceId,
|
||||
required String projectId}) async {
|
||||
try {
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.assignDeviceToRoom
|
||||
.replaceAll('{projectUuid}', projectId)
|
||||
.replaceAll('{communityUuid}', communityId)
|
||||
.replaceAll('{spaceUuid}', spaceId)
|
||||
.replaceAll('{subSpaceUuid}', subSpaceId)
|
||||
.replaceAll('{deviceUuid}', deviceId),
|
||||
expectedResponseModel: (json) {
|
||||
print('Assign Device Response: $json');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user