mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-15 17:47:28 +00:00
updated device endpoint
This commit is contained in:
@ -111,9 +111,9 @@ abstract class ApiEndpoints {
|
|||||||
//POST
|
//POST
|
||||||
static const String addDeviceToRoom = '/device/room';
|
static const String addDeviceToRoom = '/device/room';
|
||||||
static const String addDeviceToGroup = '/device/group';
|
static const String addDeviceToGroup = '/device/group';
|
||||||
static const String controlDevice = '/device/{deviceUuid}/control';
|
static const String controlDevice = '/devices/{deviceUuid}/command';
|
||||||
static const String firmwareDevice =
|
static const String firmwareDevice =
|
||||||
'/device/{deviceUuid}/firmware/{firmwareVersion}';
|
'/devices/{deviceUuid}/firmware/{firmwareVersion}';
|
||||||
static const String getDevicesByUserId = '/device/user/{userId}';
|
static const String getDevicesByUserId = '/device/user/{userId}';
|
||||||
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
static const String getDevicesByUnitId = '/device/unit/{unitUuid}';
|
||||||
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
static const String openDoorLock = '/door-lock/open/{doorLockUuid}';
|
||||||
@ -121,13 +121,13 @@ abstract class ApiEndpoints {
|
|||||||
//GET
|
//GET
|
||||||
static const String deviceByRoom =
|
static const String deviceByRoom =
|
||||||
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
|
'/projects/{projectUuid}/communities/{communityUuid}/spaces/{spaceUuid}/subspaces/{subSpaceUuid}/devices';
|
||||||
static const String deviceByUuid = '/device/{deviceUuid}';
|
static const String deviceByUuid = '/devices/{deviceUuid}';
|
||||||
static const String deviceFunctions = '/device/{deviceUuid}/functions';
|
static const String deviceFunctions = '/devices/{deviceUuid}/functions';
|
||||||
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
|
static const String gatewayApi = '/devices/gateway/{gatewayUuid}/devices';
|
||||||
static const String deviceFunctionsStatus =
|
static const String deviceFunctionsStatus =
|
||||||
'/device/{deviceUuid}/functions/status';
|
'/devices/{deviceUuid}/functions/status';
|
||||||
static const String powerClamp =
|
|
||||||
'/device/{powerClampUuid}/power-clamp/status';
|
|
||||||
|
|
||||||
///Device Permission Module
|
///Device Permission Module
|
||||||
//POST
|
//POST
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
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_category_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
import 'package:syncrow_app/features/devices/model/device_control_model.dart';
|
||||||
import 'package:syncrow_app/features/devices/model/device_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/features/devices/model/function_model.dart';
|
||||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||||
import 'package:syncrow_app/services/api/http_service.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';
|
import '../../features/devices/model/create_temporary_password_model.dart';
|
||||||
|
|
||||||
class DevicesAPI {
|
class DevicesAPI {
|
||||||
@ -39,7 +37,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||||
body: {"deviceName": deviceName},
|
body: {"deviceName": deviceName},
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
@ -92,7 +90,7 @@ class DevicesAPI {
|
|||||||
.replaceAll('{deviceUuid}', deviceId),
|
.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return response;
|
return response;
|
||||||
@ -101,7 +99,7 @@ class DevicesAPI {
|
|||||||
static Future<Map<String, dynamic>> getPowerClampStatus(
|
static Future<Map<String, dynamic>> getPowerClampStatus(
|
||||||
String deviceId) async {
|
String deviceId) async {
|
||||||
final response = await _httpService.get(
|
final response = await _httpService.get(
|
||||||
path: ApiEndpoints.powerClamp.replaceAll('{powerClampUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctionsStatus.replaceAll('{powerClampUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json;
|
||||||
@ -132,7 +130,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
final functions = FunctionModel.fromJson(json);
|
final functions = FunctionModel.fromJson(json['data']);
|
||||||
return functions;
|
return functions;
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
@ -188,7 +186,7 @@ class DevicesAPI {
|
|||||||
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
path: ApiEndpoints.deviceByUuid.replaceAll('{deviceUuid}', deviceId),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
return json;
|
return json['data'];
|
||||||
});
|
});
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@ -264,7 +262,7 @@ class DevicesAPI {
|
|||||||
if (json == null || json.isEmpty || json == []) {
|
if (json == null || json.isEmpty || json == []) {
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
for (var device in json['devices']) {
|
for (var device in json['data']['devices']) {
|
||||||
devices.add(DeviceModel.fromJson(device));
|
devices.add(DeviceModel.fromJson(device));
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
|
@ -34,7 +34,7 @@ class HomeManagementAPI {
|
|||||||
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
path: ApiEndpoints.devices.replaceAll("{projectUuid}", projectUuid),
|
||||||
showServerMessage: false,
|
showServerMessage: false,
|
||||||
expectedResponseModel: (json) {
|
expectedResponseModel: (json) {
|
||||||
json.forEach((value) {
|
json['data'].forEach((value) {
|
||||||
list.add(DeviceModel.fromJson(value));
|
list.add(DeviceModel.fromJson(value));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user