mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 17:25:47 +00:00
fetch groups
This commit is contained in:
@ -4,9 +4,11 @@ import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
class DevicesAPI {
|
||||
static final HTTPService _httpService = HTTPService();
|
||||
|
||||
static Future<Map<String, dynamic>> controlDevice(
|
||||
DeviceControlModel controlModel) async {
|
||||
final response = await HTTPService().post(
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.control,
|
||||
body: controlModel.toJson(),
|
||||
showServerMessage: false,
|
||||
@ -18,18 +20,20 @@ class DevicesAPI {
|
||||
}
|
||||
|
||||
static Future<List<DevicesCategoryModel>> fetchGroups(int spaceId) async {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.control,
|
||||
queryParameters: {'homeId': spaceId, 'pageSize': 100, 'page': 1},
|
||||
Map<String, dynamic> params = {
|
||||
"homeId": spaceId,
|
||||
"pageSize": 100,
|
||||
"page": 1
|
||||
};
|
||||
final response = await _httpService.get(
|
||||
path:
|
||||
"https://syncrow.azurewebsites.net/group?homeId=$spaceId&pageSize=100&pageNo=1",
|
||||
// path: ApiEndpoints.groups,
|
||||
// queryParameters: params,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<DevicesCategoryModel> categories = [];
|
||||
for (var category in json['groups']) {
|
||||
categories.add(DevicesCategoryModel.fromJson(category));
|
||||
}
|
||||
},
|
||||
expectedResponseModel: (json) =>
|
||||
DevicesCategoryModel.fromJsonList(json['groups']),
|
||||
);
|
||||
print('fetchGroups response: $response');
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user