From c7a4e4023e015f5d5aae46b6fdaabb6921cc795d Mon Sep 17 00:00:00 2001 From: Sultan khan <> Date: Tue, 21 May 2024 10:11:51 +0300 Subject: [PATCH 1/2] error code 699 fixes --- lib/api/api_client.dart | 13 +++++++------ lib/classes/consts.dart | 5 +++-- lib/ui/login/verify_last_login_screen.dart | 9 +++++++++ lib/ui/login/verify_login_screen.dart | 9 +++++++++ 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/lib/api/api_client.dart b/lib/api/api_client.dart index 3fbe57c..e3cbee1 100644 --- a/lib/api/api_client.dart +++ b/lib/api/api_client.dart @@ -16,13 +16,14 @@ class APIError { int? errorCode; int? errorType; String? errorMessage; - - APIError(this.errorCode, this.errorMessage, this.errorType); + int? errorStatusCode; + APIError(this.errorCode, this.errorMessage, this.errorType, this.errorStatusCode); Map toJson() => { 'errorCode': errorCode, 'errorMessage': errorMessage, 'errorType': errorType, + 'ErrorStatusCode': errorStatusCode }; @override @@ -38,14 +39,14 @@ APIException _throwAPIException(Response response) { if (response.body != null && response.body.isNotEmpty) { var jsonError = jsonDecode(response.body); print(jsonError); - apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType']); + apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType'], jsonError['ErrorStatusCode']); } return APIException(APIException.BAD_REQUEST, error: apiError); case 400: APIError? apiError; if (response.body != null && response.body.isNotEmpty) { var jsonError = jsonDecode(response.body); - apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType']); + apiError = APIError(jsonError['ErrorCode'], jsonError['ErrorMessage'], jsonError['ErrorType'],jsonError['ErrorStatusCode']); } return APIException(APIException.BAD_REQUEST, error: apiError); case 401: @@ -96,7 +97,7 @@ class ApiClient { return factoryConstructor(jsonData); } else { APIError? apiError; - apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0); + apiError = APIError(jsonData['ErrorCode'], jsonData['ErrorEndUserMessage'], jsonData['ErrorType'] ?? 0, jsonData['ErrorStatusCode']); throw APIException(APIException.BAD_REQUEST, error: apiError); } } catch (ex) { @@ -146,7 +147,7 @@ class ApiClient { } var response = await _post(Uri.parse(url), body: requestBody, headers: _headers).timeout(Duration(seconds: 120)); - if (response.statusCode >= 200 && response.statusCode < 300) { + if (response. statusCode >= 200 && response.statusCode < 300) { return response; } else { throw _throwAPIException(response); diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index aaee117..4ed76b1 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,11 +3,12 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { // static String baseUrl = "http://10.200.204.11"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + // static String baseUrl = "http://10.201.204.101:2024"; // static String baseUrl = "https://webservices.hmg.com"; // PreProd - static String baseUrl = "https://hmgwebservices.com"; // Live server + // static String baseUrl = "https://hmgwebservices.com"; // Live server static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/lib/ui/login/verify_last_login_screen.dart b/lib/ui/login/verify_last_login_screen.dart index c48d1f3..c6bd0f3 100644 --- a/lib/ui/login/verify_last_login_screen.dart +++ b/lib/ui/login/verify_last_login_screen.dart @@ -390,6 +390,15 @@ class _VerifyLastLoginScreenState extends State { } Utils.hideLoading(context); Utils.handleException(ex, context, null); + dynamic errorCode = ex; + if(errorCode.error.errorStatusCode ==699){ + Future.delayed(const Duration(seconds: 2), () + { + Navigator.pop(context); + Navigator.pushNamedAndRemoveUntil( + context, AppRoutes.login, (Route route) => false); + }); + } } } diff --git a/lib/ui/login/verify_login_screen.dart b/lib/ui/login/verify_login_screen.dart index 0147472..ac3c454 100644 --- a/lib/ui/login/verify_login_screen.dart +++ b/lib/ui/login/verify_login_screen.dart @@ -654,6 +654,15 @@ class _VerifyLoginScreenState extends State { otpFieldClear.value = ""; Utils.hideLoading(context); Utils.handleException(ex, context, null); + dynamic errorCode = ex; + if(errorCode.error.errorStatusCode ==699){ + Future.delayed(const Duration(seconds: 2), () + { + Navigator.pop(context); + Navigator.pushNamedAndRemoveUntil( + context, AppRoutes.login, (Route route) => false); + }); + } } }, () => { From f09f08be822021f7452626995450fad422ea4d0c Mon Sep 17 00:00:00 2001 From: haroon amjad Date: Wed, 29 May 2024 15:26:15 +0300 Subject: [PATCH 2/2] Store update to version 6.0 --- lib/api/dashboard_api_client.dart | 5 +++-- lib/app_state/app_state.dart | 2 +- lib/classes/consts.dart | 7 ++++--- pubspec.yaml | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/api/dashboard_api_client.dart b/lib/api/dashboard_api_client.dart index 77cc37d..bc0fece 100644 --- a/lib/api/dashboard_api_client.dart +++ b/lib/api/dashboard_api_client.dart @@ -106,7 +106,7 @@ class DashboardApiClient { } //Mark Attendance - Future markAttendance({String lat = "0", String? long = "0", required int pointType, String nfcValue = "", bool isGpsRequired = false, String QRValue = ""}) async { + Future markAttendance({String lat = "0", String? long = "0", required int pointType, String nfcValue = "", bool isGpsRequired = false, String QRValue = "", String payrollCode = ""}) async { String url = "${ApiConsts.swpRest}AuthenticateAndSwipeUserSupportNFC"; var uuid = Uuid(); // Generate a v4 (random) id @@ -120,7 +120,8 @@ class DashboardApiClient { "PointType": pointType, // NFC=2, Wifi = 3, QR= 1, "NFCValue": nfcValue, "WifiValue": pointType == 3 ? "100" : "", - "IsGpsRequired": isGpsRequired + "IsGpsRequired": isGpsRequired, + "PayrollCodeStr": AppState().postParamsObject?.payrollCodeStr.toString() ?? "" }; postParams.addAll(AppState().postParamsJson); return await ApiClient().postJsonForObject((json) { diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 3ae2097..2e8e2ad 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -90,7 +90,7 @@ class AppState { String get getHuaweiPushToken => _huaweiPushToken; - final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 5.9, mobileType: Platform.isAndroid ? "android" : "ios"); + final PostParamsModel _postParamsInitConfig = PostParamsModel(channel: 31, versionID: 6.0, mobileType: Platform.isAndroid ? "android" : "ios"); void setPostParamsInitConfig() { isAuthenticated = false; diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 4ed76b1..f5c055b 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -3,12 +3,13 @@ import 'package:mohem_flutter_app/ui/marathon/widgets/question_card.dart'; class ApiConsts { // static String baseUrl = "http://10.200.204.11"; // Local server // static String baseUrl = "https://erptstapp.srca.org.sa"; // SRCA server - static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver + // static String baseUrl = "https://uat.hmgwebservices.com"; // UAT ser343622ver // static String baseUrl = "http://10.201.204.101:2024"; - // static String baseUrl = "https://webservices.hmg.com"; // PreProd - // static String baseUrl = "https://hmgwebservices.com"; // Live server + + static String baseUrl = "https://mohemm.hmg.com"; // New Live server + static String baseUrlServices = baseUrl + "/Services/"; // server // static String baseUrlServices = "https://api.cssynapses.com/tangheem/"; // Live server static String utilitiesRest = baseUrlServices + "Utilities.svc/REST/"; diff --git a/pubspec.yaml b/pubspec.yaml index a8853ce..20ed5c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html #version: 3.3.01+300040 -version: 3.7.92+1 +version: 3.4.4+300054 environment: sdk: ">=2.16.0 <3.0.0"