mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 09:45:22 +00:00
36 lines
1.2 KiB
Dart
36 lines
1.2 KiB
Dart
import 'package:syncrow_app/features/devices/model/device_category_model.dart';
|
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
|
import 'package:syncrow_app/services/api/http_service.dart';
|
|
|
|
class DevicesAPI {
|
|
static Future<Map<String, dynamic>> controlDevice(
|
|
DeviceControlModel controlModel) async {
|
|
final response = await HTTPService().post(
|
|
path: ApiEndpoints.control,
|
|
body: controlModel.toJson(),
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) {
|
|
return json;
|
|
},
|
|
);
|
|
return response;
|
|
}
|
|
|
|
static Future<List<DevicesCategoryModel>> fetchGroups(int spaceId) async {
|
|
final response = await HTTPService().get(
|
|
path: ApiEndpoints.control,
|
|
queryParameters: {'homeId': spaceId, 'pageSize': 100, 'page': 1},
|
|
showServerMessage: false,
|
|
expectedResponseModel: (json) {
|
|
List<DevicesCategoryModel> categories = [];
|
|
for (var category in json['groups']) {
|
|
categories.add(DevicesCategoryModel.fromJson(category));
|
|
}
|
|
},
|
|
);
|
|
print('fetchGroups response: $response');
|
|
return response;
|
|
}
|
|
}
|