update devices

This commit is contained in:
mohammad
2024-06-26 11:53:32 +03:00
parent 1fb8a8d035
commit ea4dc852f8
12 changed files with 190 additions and 59 deletions

View File

@ -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,