mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
visitor password
This commit is contained in:
@ -1,36 +1,37 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:syncrow_web/pages/access_management/model/access_manag_model.dart';
|
||||
import 'package:syncrow_web/pages/auth/model/user_model.dart';
|
||||
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/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
class AccessMangApi{
|
||||
|
||||
// Future<List<AccessManagModel>> fetchInfo() async {
|
||||
// final response = await HTTPService().get(
|
||||
// path: '/Users/mohammad/StudioProjects/web_auth/assets/demo.json',
|
||||
// showServerMessage: true,
|
||||
// expectedResponseModel: (json) {
|
||||
// print('fetchInfo=$json');
|
||||
// return (json as List).map((item) => AccessManagModel.fromJson(item)).toList();
|
||||
// },
|
||||
// );
|
||||
// return response;
|
||||
// }
|
||||
|
||||
Future<List<AccessManagModel>> fetchInfo() async {
|
||||
// Load the JSON file
|
||||
final jsonString = await rootBundle.loadString('assets/dome.json');
|
||||
|
||||
// Parse the JSON string
|
||||
final List<dynamic> jsonList = json.decode(jsonString);
|
||||
print('jsonList=${jsonList.runtimeType}');
|
||||
print('jsonList=${jsonList}');
|
||||
// Convert the list of JSON objects to a list of AccessManagModel instances
|
||||
final List<AccessManagModel> accessList = jsonList.map((item) => AccessManagModel.fromJson(item)).toList();
|
||||
|
||||
return accessList;
|
||||
Future<List<PasswordModel>> fetchVisitorPassword() async {
|
||||
try {
|
||||
final response = await HTTPService().get(
|
||||
path: ApiEndpoints.visitorPassword,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
List<dynamic> jsonData = json;
|
||||
print('Password List: $json');
|
||||
List<PasswordModel> passwordList = jsonData.map((jsonItem) {
|
||||
return PasswordModel.fromJson(jsonItem);
|
||||
}).toList();
|
||||
return passwordList;
|
||||
},
|
||||
);
|
||||
return response;
|
||||
} catch (e) {
|
||||
debugPrint('Error fetching visitor passwords: $e');
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -50,8 +50,7 @@ class AuthenticationAPI {
|
||||
}
|
||||
);
|
||||
return 30;
|
||||
} on DioError catch (e) {
|
||||
|
||||
} on DioException catch (e) {
|
||||
if (e.response != null) {
|
||||
if (e.response!.statusCode == 400) {
|
||||
// Handle 400 Bad Request
|
||||
@ -64,7 +63,6 @@ class AuthenticationAPI {
|
||||
int cooldown = errorData['data']['cooldown'] ?? 1;
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
} else {
|
||||
debugPrint('Error: ${e.response!.statusCode} - ${e.response!.statusMessage}');
|
||||
return 1;
|
||||
@ -73,7 +71,6 @@ class AuthenticationAPI {
|
||||
debugPrint('Error: ${e.message}');
|
||||
return 1;
|
||||
}
|
||||
return 1;
|
||||
} catch (e) {
|
||||
debugPrint('Unexpected Error: $e');
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user