mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 23:37:54 +00:00
Added latest changes from dev and solved conflicts
This commit is contained in:
@@ -9,8 +9,7 @@ abstract class ApiEndpoints {
|
||||
static const String deleteUser = '$baseUrl/authentication/user/delete/{id}';
|
||||
static const String sendOtp = '$baseUrl/authentication/user/send-otp';
|
||||
static const String verifyOtp = '$baseUrl/authentication/user/verify-otp';
|
||||
static const String forgetPassword =
|
||||
'$baseUrl/authentication/user/forget-password';
|
||||
static const String forgetPassword = '$baseUrl/authentication/user/forget-password';
|
||||
|
||||
////////////////////////////////////// Spaces ///////////////////////////////////////
|
||||
|
||||
@@ -20,12 +19,10 @@ abstract class ApiEndpoints {
|
||||
static const String addCommunityToUser = '$baseUrl/community/user';
|
||||
//GET
|
||||
static const String communityByUuid = '$baseUrl/community/{communityUuid}';
|
||||
static const String communityChild =
|
||||
'$baseUrl/community/child/{communityUuid}';
|
||||
static const String communityChild = '$baseUrl/community/child/{communityUuid}';
|
||||
static const String communityUser = '$baseUrl/community/user/{userUuid}';
|
||||
//PUT
|
||||
static const String renameCommunity =
|
||||
'$baseUrl/community/rename/{communityUuid}';
|
||||
static const String renameCommunity = '$baseUrl/community/rename/{communityUuid}';
|
||||
|
||||
///Building Module
|
||||
//POST
|
||||
@@ -34,12 +31,10 @@ abstract class ApiEndpoints {
|
||||
//GET
|
||||
static const String buildingByUuid = '$baseUrl/building/{buildingUuid}';
|
||||
static const String buildingChild = '$baseUrl/building/child/{buildingUuid}';
|
||||
static const String buildingParent =
|
||||
'$baseUrl/building/parent/{buildingUuid}';
|
||||
static const String buildingParent = '$baseUrl/building/parent/{buildingUuid}';
|
||||
static const String buildingUser = '$baseUrl/building/user/{userUuid}';
|
||||
//PUT
|
||||
static const String renameBuilding =
|
||||
'$baseUrl/building/rename/{buildingUuid}';
|
||||
static const String renameBuilding = '$baseUrl/building/rename/{buildingUuid}';
|
||||
|
||||
///Floor Module
|
||||
//POST
|
||||
@@ -62,8 +57,7 @@ abstract class ApiEndpoints {
|
||||
static const String unitChild = '$baseUrl/unit/child/';
|
||||
static const String unitParent = '$baseUrl/unit/parent/{unitUuid}';
|
||||
static const String unitUser = '$baseUrl/unit/user/';
|
||||
static const String invitationCode =
|
||||
'$baseUrl/unit/{unitUuid}/invitation-code';
|
||||
static const String invitationCode = '$baseUrl/unit/{unitUuid}/invitation-code';
|
||||
static const String verifyInvitationCode = '$baseUrl/unit/user/verify-code';
|
||||
|
||||
//PUT
|
||||
@@ -85,7 +79,9 @@ abstract class ApiEndpoints {
|
||||
static const String addGroup = '$baseUrl/group';
|
||||
static const String controlGroup = '$baseUrl/group/control';
|
||||
//GET
|
||||
static const String groupBySpace = '$baseUrl/group/space/{spaceUuid}';
|
||||
static const String groupBySpace = '$baseUrl/group/{unitUuid}';
|
||||
static const String devicesByGroupName = '$baseUrl/group/{unitUuid}/devices/{groupName}';
|
||||
|
||||
static const String groupByUuid = '$baseUrl/group/{groupUuid}';
|
||||
//DELETE
|
||||
static const String deleteGroup = '$baseUrl/group/{groupUuid}';
|
||||
@@ -96,15 +92,15 @@ abstract class ApiEndpoints {
|
||||
static const String addDeviceToRoom = '$baseUrl/device/room';
|
||||
static const String addDeviceToGroup = '$baseUrl/device/group';
|
||||
static const String controlDevice = '$baseUrl/device/{deviceUuid}/control';
|
||||
static const String firmwareDevice = '$baseUrl/device/{deviceUuid}/firmware/{firmwareVersion}';
|
||||
static const String getDevicesByUserId = '$baseUrl/device/user/{userId}';
|
||||
|
||||
//GET
|
||||
static const String deviceByRoom = '$baseUrl/device/room';
|
||||
static const String deviceByUuid = '$baseUrl/device/{deviceUuid}';
|
||||
static const String deviceFunctions =
|
||||
'$baseUrl/device/{deviceUuid}/functions';
|
||||
static const String deviceFunctionsStatus =
|
||||
'$baseUrl/device/{deviceUuid}/functions/status';
|
||||
static const String deviceFunctions = '$baseUrl/device/{deviceUuid}/functions';
|
||||
static const String gatewayApi = '$baseUrl/device/gateway/{gatewayUuid}/devices';
|
||||
static const String deviceFunctionsStatus = '$baseUrl/device/{deviceUuid}/functions/status';
|
||||
|
||||
///Device Permission Module
|
||||
//POST
|
||||
@@ -112,16 +108,14 @@ abstract class ApiEndpoints {
|
||||
//GET
|
||||
static const String devicePermissionList = '$baseUrl/device-permission/list';
|
||||
//PUT
|
||||
static const String editDevicePermission =
|
||||
'$baseUrl/device-permission/edit/{userId}';
|
||||
static const String editDevicePermission = '$baseUrl/device-permission/edit/{userId}';
|
||||
|
||||
static const String assignDeviceToRoom = '$baseUrl/device/room';
|
||||
|
||||
/// Scene API ////////////////////
|
||||
/// POST
|
||||
static const String createScene = '$baseUrl/scene/tap-to-run';
|
||||
static const String triggerScene =
|
||||
'$baseUrl/scene/tap-to-run/trigger/{sceneId}';
|
||||
static const String triggerScene = '$baseUrl/scene/tap-to-run/trigger/{sceneId}';
|
||||
|
||||
/// GET
|
||||
static const String getUnitScenes = '$baseUrl/scene/tap-to-run/{unitUuid}';
|
||||
@@ -132,6 +126,28 @@ abstract class ApiEndpoints {
|
||||
static const String updateScene = '$baseUrl/scene/{sceneId}';
|
||||
|
||||
/// DELETE
|
||||
static const String deleteScene =
|
||||
'$baseUrl/scene/tap-to-run/{sceneUuid}/{sceneId}';
|
||||
static const String deleteScene = '$baseUrl/scene/tap-to-run/{sceneUuid}/{sceneId}';
|
||||
|
||||
//////////////////////Door Lock //////////////////////
|
||||
//online
|
||||
static const String addTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/online/{doorLockUuid}';
|
||||
static const String getTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/online/{doorLockUuid}';
|
||||
|
||||
//one-time offline
|
||||
static const String addOneTimeTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/offline/one-time/{doorLockUuid}';
|
||||
static const String getOneTimeTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/offline/one-time/{doorLockUuid}';
|
||||
|
||||
//multiple-time offline
|
||||
static const String addMultipleTimeTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
|
||||
static const String getMultipleTimeTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
|
||||
|
||||
//multiple-time offline
|
||||
static const String deleteTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/{doorLockUuid}/{passwordId}';
|
||||
}
|
||||
|
||||
@@ -40,4 +40,14 @@ class AuthenticationAPI {
|
||||
expectedResponseModel: (json) => json['data']);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> forgetPassword({required String email,required String password ,}) async {
|
||||
Map<String, dynamic> params = {"email": email, "password": password,};
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.forgetPassword,
|
||||
body: params,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json['data']);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
@@ -7,9 +6,29 @@ 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 '../../features/devices/model/create_temporary_password_model.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;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> controlDevice(
|
||||
DeviceControlModel controlModel, String deviceId) async {
|
||||
try {
|
||||
@@ -28,26 +47,20 @@ 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,
|
||||
path: ApiEndpoints.groupBySpace.replaceAll('{unitUuid}', spaceId),
|
||||
// queryParameters: params,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) =>
|
||||
DevicesCategoryModel.fromJsonList(json['groups']),
|
||||
expectedResponseModel: (json) => DevicesCategoryModel.fromJsonList(json),
|
||||
);
|
||||
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;
|
||||
@@ -59,18 +72,36 @@ class DevicesAPI {
|
||||
/// Get Device Functions
|
||||
static Future<FunctionModel> deviceFunctions(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
||||
path: ApiEndpoints.deviceFunctions.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
final functions = FunctionModel.fromJson(json);
|
||||
return functions;
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDeviceByGroupName(String unitId, String groupName) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.devicesByGroupName
|
||||
.replaceAll('{unitUuid}', unitId)
|
||||
.replaceAll('{groupName}', groupName),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
final functions = FunctionModel.fromJson(json);
|
||||
return functions;
|
||||
if (json == null || json.isEmpty || json == []) {
|
||||
return <DeviceModel>[];
|
||||
}
|
||||
List<DeviceModel> devices = [];
|
||||
for (var device in json) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
return devices;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByRoomId(String roomId) async {
|
||||
// print("Room ID: $roomId");
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.deviceByRoom,
|
||||
queryParameters: {"roomUuid": roomId},
|
||||
@@ -88,4 +119,90 @@ class DevicesAPI {
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
List<DeviceModel> devices = [];
|
||||
if (json == null || json.isEmpty || json == []) {
|
||||
return devices;
|
||||
}
|
||||
for (var device in json['devices']) {
|
||||
devices.add(DeviceModel.fromJson(device));
|
||||
}
|
||||
return devices;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future getTemporaryPasswords(String deviceId, pageType) async {
|
||||
final response = await _httpService.get(
|
||||
path: pageType == 'One-Time'
|
||||
? ApiEndpoints.getOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId)
|
||||
: pageType == 'Online Password'
|
||||
? ApiEndpoints.getTemporaryPassword.replaceAll('{doorLockUuid}', deviceId)
|
||||
: ApiEndpoints.getMultipleTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
//create password
|
||||
static Future createPassword({
|
||||
required String name,
|
||||
required String password,
|
||||
required String effectiveTime,
|
||||
required String invalidTime,
|
||||
required String deviceId,
|
||||
required String pageType,
|
||||
List<Schedule>? scheduleList,
|
||||
}) async {
|
||||
String endpointPath;
|
||||
if (pageType == 'Online Password') {
|
||||
endpointPath = ApiEndpoints.addTemporaryPassword.replaceAll('{doorLockUuid}', deviceId);
|
||||
} else if (pageType == 'One-Time') {
|
||||
endpointPath =
|
||||
ApiEndpoints.addOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId);
|
||||
} else {
|
||||
endpointPath =
|
||||
ApiEndpoints.addMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId);
|
||||
}
|
||||
Map<String, dynamic> body = {
|
||||
"name": name,
|
||||
"password": password,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime,
|
||||
};
|
||||
if (pageType == 'Online Password' && scheduleList != null) {
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
final response = await _httpService.post(
|
||||
path: endpointPath,
|
||||
body: body,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json,
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> deletePassword(
|
||||
{required String passwordId, required String deviceId}) async {
|
||||
final response = await _httpService.delete(
|
||||
path: ApiEndpoints.deleteTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId)
|
||||
.replaceAll('{passwordId}', passwordId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user