mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Success dialog and Failed dialog changes with VisitorPasswordDialog
This commit is contained in:
@ -2,12 +2,11 @@ import 'dart:convert';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:syncrow_web/pages/access_management/model/password_model.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/model/device_model.dart';
|
||||
import 'package:syncrow_web/pages/visitor_password/model/schedule_model.dart';
|
||||
import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
import '../pages/visitor_password/model/device_model.dart';
|
||||
|
||||
class AccessMangApi{
|
||||
|
||||
Future<List<PasswordModel>> fetchVisitorPassword() async {
|
||||
@ -17,7 +16,6 @@ class AccessMangApi{
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
print('Password List: $json');
|
||||
List<PasswordModel> passwordList = jsonData.map((jsonItem) {
|
||||
return PasswordModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -38,7 +36,6 @@ class AccessMangApi{
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
print('fetchDevices List: $json');
|
||||
List<DeviceModel> passwordList = jsonData.map((jsonItem) {
|
||||
return DeviceModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
@ -60,18 +57,6 @@ class AccessMangApi{
|
||||
String? invalidTime,
|
||||
List<String>? devicesUuid}) async {
|
||||
try {
|
||||
|
||||
print('postOfflineOneTime List: ${
|
||||
jsonEncode({
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"password": password,
|
||||
"devicesUuid": devicesUuid,
|
||||
"effectiveTime":effectiveTime ,
|
||||
"invalidTime": invalidTime
|
||||
})
|
||||
}');
|
||||
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOnlineOneTime,
|
||||
body: jsonEncode({
|
||||
@ -84,7 +69,6 @@ class AccessMangApi{
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('postOfflineOneTime List: $json');
|
||||
if(json['statusCode'].toString()=='201'){
|
||||
return true;
|
||||
}else{
|
||||
@ -93,9 +77,8 @@ class AccessMangApi{
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} on DioException catch (e) {
|
||||
} on DioException catch (e) {
|
||||
debugPrint('Error: ${e.message}');
|
||||
|
||||
debugPrint('Error fetching ${e.response!.statusMessage}');
|
||||
return false;
|
||||
}
|
||||
@ -121,15 +104,11 @@ class AccessMangApi{
|
||||
if (scheduleList != null) {
|
||||
body["scheduleList"] = scheduleList.map((schedule) => schedule.toJson()).toList();
|
||||
}
|
||||
print('createPassword =${jsonEncode(body)}');
|
||||
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOnlineMultipleTime,
|
||||
body: jsonEncode(body),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('createPassword =${json}');
|
||||
|
||||
if(json['data']['successOperations'][0]['success'].toString()=='true'){
|
||||
return true;
|
||||
}else{
|
||||
@ -138,7 +117,7 @@ class AccessMangApi{
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} on DioException catch (e){
|
||||
} on DioException catch (e){
|
||||
debugPrint('Error fetching ${e.type.name}');
|
||||
debugPrint('Error fetching ${e.response!.statusMessage}');
|
||||
return false;
|
||||
@ -149,15 +128,6 @@ class AccessMangApi{
|
||||
|
||||
Future postOffLineOneTime({String? email,String? passwordName,List<String>? devicesUuid}) async {
|
||||
try {
|
||||
|
||||
print('postOfflineOneTime List: ${
|
||||
{
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"devicesUuid": devicesUuid
|
||||
}
|
||||
}');
|
||||
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOffLineOneTime,
|
||||
body: jsonEncode({
|
||||
@ -166,10 +136,14 @@ class AccessMangApi{
|
||||
"devicesUuid": devicesUuid
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
print('postOfflineOneTime List: $json');
|
||||
},
|
||||
expectedResponseModel: (json) {
|
||||
if (json['data']['successOperations'][0]['success'].toString() ==
|
||||
'true') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
@ -187,15 +161,6 @@ class AccessMangApi{
|
||||
|
||||
}) async {
|
||||
try {
|
||||
|
||||
print('postOfflineOneTime List: ${
|
||||
{
|
||||
"email": email,
|
||||
"passwordName": passwordName,
|
||||
"devicesUuid": devicesUuid
|
||||
}
|
||||
}');
|
||||
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.sendOffLineOneTime,
|
||||
body: jsonEncode({
|
||||
@ -206,10 +171,14 @@ class AccessMangApi{
|
||||
"invalidTime": invalidTime
|
||||
}),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
print('postOfflineOneTime List: $json');
|
||||
},
|
||||
expectedResponseModel: (json) {
|
||||
if (json['data']['successOperations'][0]['success'].toString() ==
|
||||
'true') {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
|
@ -1,4 +1,3 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
@ -8,9 +7,7 @@ import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
class AuthenticationAPI {
|
||||
|
||||
static Future<Token> loginWithEmail({required var model}) async {
|
||||
print('model=$model');
|
||||
final response = await HTTPService().post(
|
||||
path: ApiEndpoints.login,
|
||||
body: model.toJson(),
|
||||
@ -46,19 +43,15 @@ class AuthenticationAPI {
|
||||
},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('object==$json');
|
||||
return 30;
|
||||
}
|
||||
|
||||
);
|
||||
return 30;
|
||||
} on DioException catch (e) {
|
||||
if (e.response != null) {
|
||||
if (e.response!.statusCode == 400) {
|
||||
// Handle 400 Bad Request
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
debugPrint('Unexpected Error: $errorMessage');
|
||||
if(errorMessage=='User not found'){
|
||||
return 1;
|
||||
}else{
|
||||
@ -87,8 +80,6 @@ class AuthenticationAPI {
|
||||
body: {"email": email, "type": "PASSWORD", "otpCode": otpCode},
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
print('json=$json');
|
||||
|
||||
if (json['message'] == 'Otp Verified Successfully') {
|
||||
return true;
|
||||
} else {
|
||||
@ -99,12 +90,9 @@ class AuthenticationAPI {
|
||||
}on DioException catch (e){
|
||||
if (e.response != null) {
|
||||
if (e.response!.statusCode == 400) {
|
||||
// Handle 400 Bad Request
|
||||
final errorData = e.response!.data;
|
||||
String errorMessage = errorData['message'];
|
||||
debugPrint('Unexpected Error: $errorMessage');
|
||||
return errorMessage;
|
||||
|
||||
}
|
||||
} else {
|
||||
debugPrint('Error: ${e.message}');
|
||||
|
Reference in New Issue
Block a user