mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-24 11:37:55 +00:00
door lock
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
abstract class ApiEndpoints {
|
||||
static const String baseUrl = 'https://syncrow.azurewebsites.net';
|
||||
static const String baseUrl = 'https://syncrow-dev.azurewebsites.net';
|
||||
// static const String baseUrl = 'http://100.107.182.63:4001'; //Localhost
|
||||
|
||||
////////////////////////////////////// Authentication ///////////////////////////////
|
||||
@@ -148,6 +148,9 @@ abstract class ApiEndpoints {
|
||||
static const String getMultipleTimeTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/offline/multiple-time/{doorLockUuid}';
|
||||
|
||||
static const String renamePassword =
|
||||
'$baseUrl/door-lock/temporary-password/{doorLockUuid}/offline/{passwordId}';
|
||||
|
||||
//multiple-time offline
|
||||
static const String deleteTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/{doorLockUuid}/{passwordId}';
|
||||
|
||||
@@ -3,6 +3,7 @@ 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';
|
||||
import 'package:syncrow_app/features/devices/model/function_model.dart';
|
||||
import 'package:syncrow_app/features/devices/model/offline_temporary_password.dart';
|
||||
import 'package:syncrow_app/services/api/api_links_endpoints.dart';
|
||||
import 'package:syncrow_app/services/api/http_service.dart';
|
||||
|
||||
@@ -69,6 +70,22 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> renamePass({
|
||||
required String name,
|
||||
required String deviceId,
|
||||
required String passwordId}) async {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.renamePassword.replaceAll('{deviceUuid}', deviceId).replaceAll('{passwordId}', passwordId),
|
||||
body: {
|
||||
"name": name
|
||||
},
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// Get Device Functions
|
||||
static Future<FunctionModel> deviceFunctions(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
@@ -140,12 +157,8 @@ class DevicesAPI {
|
||||
|
||||
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),
|
||||
path:
|
||||
ApiEndpoints.getTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@@ -190,6 +203,40 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future generateOneTimePassword({deviceId}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future generateMultiTimePassword({deviceId,effectiveTime,invalidTime}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
body: {
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime
|
||||
},
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> deletePassword(
|
||||
{required String passwordId, required String deviceId}) async {
|
||||
final response = await _httpService.delete(
|
||||
|
||||
Reference in New Issue
Block a user