mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-14 17:25:47 +00:00
update devices
This commit is contained in:
@ -9,6 +9,27 @@ import 'package:syncrow_app/services/api/http_service.dart';
|
||||
class DevicesAPI {
|
||||
static final HTTPService _httpService = HTTPService();
|
||||
|
||||
static Future<Map<String, dynamic>> firmwareDevice(
|
||||
{
|
||||
required String deviceId,
|
||||
required String firmwareVersion}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.firmwareDevice
|
||||
.replaceAll('{deviceUuid}', deviceId)
|
||||
.replaceAll('{firmwareVersion}', firmwareVersion),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
print('response==$response');
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> controlDevice(
|
||||
DeviceControlModel controlModel, String deviceId) async {
|
||||
try {
|
||||
@ -27,20 +48,26 @@ class DevicesAPI {
|
||||
}
|
||||
|
||||
static Future<List<DevicesCategoryModel>> fetchGroups(String spaceId) async {
|
||||
Map<String, dynamic> params = {"homeId": spaceId, "pageSize": 100, "pageNo": 1};
|
||||
Map<String, dynamic> params = {
|
||||
"homeId": spaceId,
|
||||
"pageSize": 100,
|
||||
"pageNo": 1
|
||||
};
|
||||
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.groupBySpace.replaceAll("{spaceUuid}", spaceId),
|
||||
queryParameters: params,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json['groups']),
|
||||
expectedResponseModel: (json) =>
|
||||
DevicesCategoryModel.fromJsonList(json['groups']),
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> getDeviceStatus(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{deviceUuid}', deviceId),
|
||||
path: ApiEndpoints.deviceFunctionsStatus
|
||||
.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -68,7 +95,8 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
|
Reference in New Issue
Block a user