mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-11-26 08:44:54 +00:00
door sensor
This commit is contained in:
@ -39,7 +39,6 @@ class DevicesAPI {
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
@ -72,7 +71,8 @@ class DevicesAPI {
|
||||
|
||||
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;
|
||||
@ -82,7 +82,9 @@ class DevicesAPI {
|
||||
}
|
||||
|
||||
static Future<Map<String, dynamic>> renamePass(
|
||||
{required String name, required String doorLockUuid, required String passwordId}) async {
|
||||
{required String name,
|
||||
required String doorLockUuid,
|
||||
required String passwordId}) async {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.renamePassword
|
||||
.replaceAll('{doorLockUuid}', doorLockUuid)
|
||||
@ -107,7 +109,8 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDeviceByGroupName(String unitId, String groupName) async {
|
||||
static Future<List<DeviceModel>> getDeviceByGroupName(
|
||||
String unitId, String groupName) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.devicesByGroupName
|
||||
.replaceAll('{unitUuid}', unitId)
|
||||
@ -146,7 +149,8 @@ class DevicesAPI {
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(String gatewayId) async {
|
||||
static Future<List<DeviceModel>> getDevicesByGatewayId(
|
||||
String gatewayId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.gatewayApi.replaceAll('{gatewayUuid}', gatewayId),
|
||||
showServerMessage: false,
|
||||
@ -168,7 +172,8 @@ class DevicesAPI {
|
||||
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;
|
||||
@ -179,7 +184,8 @@ class DevicesAPI {
|
||||
|
||||
static Future getOneTimePasswords(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.getOneTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -190,7 +196,8 @@ class DevicesAPI {
|
||||
|
||||
static Future getTimeLimitPasswords(String deviceId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.getMultipleTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -215,10 +222,12 @@ class DevicesAPI {
|
||||
"invalidTime": invalidTime,
|
||||
};
|
||||
if (scheduleList != null) {
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
body["scheduleList"] =
|
||||
scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.addTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
body: body,
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) => json,
|
||||
@ -229,7 +238,8 @@ class DevicesAPI {
|
||||
static Future generateOneTimePassword({deviceId}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addOneTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.addOneTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -241,10 +251,12 @@ class DevicesAPI {
|
||||
}
|
||||
}
|
||||
|
||||
static Future generateMultiTimePassword({deviceId, effectiveTime, invalidTime}) async {
|
||||
static Future generateMultiTimePassword(
|
||||
{deviceId, effectiveTime, invalidTime}) async {
|
||||
try {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.addMultipleTimeTemporaryPassword.replaceAll('{doorLockUuid}', deviceId),
|
||||
path: ApiEndpoints.addMultipleTimeTemporaryPassword
|
||||
.replaceAll('{doorLockUuid}', deviceId),
|
||||
showServerMessage: true,
|
||||
body: {"effectiveTime": effectiveTime, "invalidTime": invalidTime},
|
||||
expectedResponseModel: (json) {
|
||||
@ -277,21 +289,22 @@ class DevicesAPI {
|
||||
required String time,
|
||||
required String code,
|
||||
required bool value,
|
||||
required List<String> days,
|
||||
required List<String> days,
|
||||
}) async {
|
||||
final response = await _httpService.post(
|
||||
path: ApiEndpoints.saveSchedule.replaceAll('{deviceUuid}', deviceId),
|
||||
showServerMessage: false,
|
||||
body:
|
||||
jsonEncode({
|
||||
"category": category,
|
||||
"time": time,
|
||||
"function":{
|
||||
"code": code,
|
||||
"value":value,
|
||||
body: jsonEncode(
|
||||
{
|
||||
"category": category,
|
||||
"time": time,
|
||||
"function": {
|
||||
"code": code,
|
||||
"value": value,
|
||||
},
|
||||
"days": days
|
||||
},
|
||||
"days": days
|
||||
},),
|
||||
),
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
@ -304,7 +317,9 @@ class DevicesAPI {
|
||||
required String deviceId,
|
||||
}) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getSchedule.replaceAll('{deviceUuid}', deviceId).replaceAll('{category}', category),
|
||||
path: ApiEndpoints.getSchedule
|
||||
.replaceAll('{deviceUuid}', deviceId)
|
||||
.replaceAll('{category}', category),
|
||||
showServerMessage: false,
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
@ -320,10 +335,7 @@ class DevicesAPI {
|
||||
}) async {
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.changeSchedule.replaceAll('{deviceUuid}', deviceUuid),
|
||||
body: {
|
||||
"scheduleId": scheduleId,
|
||||
"enable": enable
|
||||
},
|
||||
body: {"scheduleId": scheduleId, "enable": enable},
|
||||
expectedResponseModel: (json) {
|
||||
return json['success'];
|
||||
},
|
||||
@ -336,11 +348,36 @@ class DevicesAPI {
|
||||
required String scheduleId,
|
||||
}) async {
|
||||
final response = await _httpService.delete(
|
||||
path: ApiEndpoints.deleteSchedule.replaceAll('{deviceUuid}', deviceUuid).replaceAll('{scheduleId}', scheduleId),
|
||||
path: ApiEndpoints.deleteSchedule
|
||||
.replaceAll('{deviceUuid}', deviceUuid)
|
||||
.replaceAll('{scheduleId}', scheduleId),
|
||||
expectedResponseModel: (json) {
|
||||
return json;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
}
|
||||
|
||||
static Future getReportLogs({
|
||||
required String deviceUuid,
|
||||
required String code,
|
||||
required String startTime,
|
||||
required String endTime,
|
||||
}) async {
|
||||
// print(
|
||||
// '---------${ApiEndpoints.reportLogs.replaceAll('{deviceUuid}', deviceUuid).replaceAll('{code}', code).replaceAll('{startTime}', startTime).replaceAll('{endTime}', endTime)}');
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.reportLogs
|
||||
.replaceAll('{deviceUuid}', deviceUuid)
|
||||
.replaceAll('{code}', code)
|
||||
.replaceAll('{startTime}', startTime)
|
||||
.replaceAll('{endTime}', endTime),
|
||||
expectedResponseModel: (json) {
|
||||
print('====---------${json}');
|
||||
return json;
|
||||
},
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user