updated device endpoint

This commit is contained in:
hannathkadher
2025-04-03 10:47:09 +04:00
parent ef5e7c3154
commit fb867e5df3
3 changed files with 15 additions and 17 deletions

View File

@ -111,9 +111,9 @@ abstract class ApiEndpoints {
//POST
static const String addDeviceToRoom = '/device/room';
static const String addDeviceToGroup = '/device/group';
static const String controlDevice = '/device/{deviceUuid}/control';
static const String controlDevice = '/devices/{deviceUuid}/command';
static const String firmwareDevice =
'/device/{deviceUuid}/firmware/{firmwareVersion}';
'/devices/{deviceUuid}/firmware/{firmwareVersion}';
static const String getDevicesByUserId = '/device/user/{userId}';
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
@ -121,13 +121,13 @@ abstract class ApiEndpoints {
//GET
static const String deviceByRoom =
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
static const String deviceByUuid = '/device/{deviceUuid}';
static const String deviceFunctions = '/device/{deviceUuid}/functions';
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
static const String deviceByUuid = '/devices/{deviceUuid}';
static const String deviceFunctions = '/devices/{deviceUuid}/functions';
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
static const String deviceFunctionsStatus =
'/device/{deviceUuid}/functions/status';
static const String powerClamp =
'/device/{powerClampUuid}/power-clamp/status';
'/devices/{deviceUuid}/functions/status';
///Device Permission Module
//POST

View File

@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
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/features/devices/model/device_model.dart';
@ -8,7 +7,6 @@ import 'package:syncrow_app/features/devices/model/device_report_model.dart';
import 'package:syncrow_app/features/devices/model/function_model.dart';
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
import 'package:syncrow_app/services/api/http_service.dart';
import 'package:syncrow_app/utils/constants/temp_const.dart';
import '../../features/devices/model/create_temporary_password_model.dart';
class DevicesAPI {
@ -39,7 +37,7 @@ class DevicesAPI {
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
body: {"deviceName": deviceName},
expectedResponseModel: (json) {
return json;
return json['data'];
},
);
return response;
@ -92,7 +90,7 @@ class DevicesAPI {
.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
return json;
return json['data'];
},
);
return response;
@ -101,7 +99,7 @@ class DevicesAPI {
static Future<Map<String, dynamic>> getPowerClampStatus(
String deviceId) async {
final response = await _httpService.get(
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{powerClampUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
return json;
@ -132,7 +130,7 @@ class DevicesAPI {
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
final functions = FunctionModel.fromJson(json);
final functions = FunctionModel.fromJson(json['data']);
return functions;
});
return response;
@ -188,7 +186,7 @@ class DevicesAPI {
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
showServerMessage: false,
expectedResponseModel: (json) {
return json;
return json['data'];
});
return response;
}
@ -264,7 +262,7 @@ class DevicesAPI {
if (json == null || json.isEmpty || json == []) {
return devices;
}
for (var device in json['devices']) {
for (var device in json['data']['devices']) {
devices.add(DeviceModel.fromJson(device));
}
return devices;

View File

@ -34,7 +34,7 @@ class HomeManagementAPI {
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
showServerMessage: false,
expectedResponseModel: (json) {
json.forEach((value) {
json['data'].forEach((value) {
list.add(DeviceModel.fromJson(value));
});
});