mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2026-10-23 22:07:55 +00:00
door lock
This commit is contained in:
@@ -153,5 +153,5 @@ abstract class ApiEndpoints {
|
||||
|
||||
//multiple-time offline
|
||||
static const String deleteTemporaryPassword =
|
||||
'$baseUrl/door-lock/temporary-password/{doorLockUuid}/{passwordId}';
|
||||
'$baseUrl/door-lock/temporary-password/online/{doorLockUuid}/{passwordId}';
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import 'dart:async';
|
||||
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';
|
||||
@@ -72,10 +73,12 @@ class DevicesAPI {
|
||||
|
||||
static Future<Map<String, dynamic>> renamePass({
|
||||
required String name,
|
||||
required String deviceId,
|
||||
required String doorLockUuid,
|
||||
required String passwordId}) async {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.renamePassword.replaceAll('{deviceUuid}', deviceId).replaceAll('{passwordId}', passwordId),
|
||||
path: ApiEndpoints.renamePassword
|
||||
.replaceAll('{doorLockUuid}', doorLockUuid)
|
||||
.replaceAll('{passwordId}', passwordId),
|
||||
body: {
|
||||
"name": name
|
||||
},
|
||||
@@ -155,10 +158,9 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future getTemporaryPasswords(String deviceId, pageType) async {
|
||||
static Future getTemporaryPasswords(String deviceId, ) async {
|
||||
final response = await _httpService.get(
|
||||
path:
|
||||
ApiEndpoints.getTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.getTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@@ -167,35 +169,50 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
//create password
|
||||
static Future getOneTimePasswords(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
log('==============$json');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future getTimeLimitPasswords(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
print('00000000$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);
|
||||
}
|
||||
List<Schedule>? scheduleList,}) async {
|
||||
|
||||
Map<String, dynamic> body = {
|
||||
"name": name,
|
||||
"password": password,
|
||||
"effectiveTime": effectiveTime,
|
||||
"invalidTime": invalidTime,
|
||||
};
|
||||
if (pageType == 'Online Password' && scheduleList != null) {
|
||||
if (scheduleList != null) {
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
final response = await _httpService.post(
|
||||
path: endpointPath,
|
||||
path: ApiEndpoints.addTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
body: body,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json,
|
||||
@@ -209,6 +226,7 @@ class DevicesAPI {
|
||||
path: ApiEndpoints.addOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
print('generateOneTimePassword=${json}');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
@@ -250,4 +268,6 @@ class DevicesAPI {
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user