From 8149ef2a5bc57ce51ce272a5c31e297e0ae4feba Mon Sep 17 00:00:00 2001 From: asif Date: Wed, 10 Dec 2025 11:50:02 +0530 Subject: [PATCH] Sim Binding Done #1 --- lib/api/services/auth_service.dart | 92 +++++++++++++------ .../auth/screens/verification_screen.dart | 2 +- 2 files changed, 63 insertions(+), 31 deletions(-) diff --git a/lib/api/services/auth_service.dart b/lib/api/services/auth_service.dart index 92c2219..e66538e 100644 --- a/lib/api/services/auth_service.dart +++ b/lib/api/services/auth_service.dart @@ -8,41 +8,73 @@ class AuthService { final Dio _dio; AuthService(this._dio); - Future simVerify(String uuid, String cifNo) async{ - try{ - final response = await _dio.post( - '/api/sim-details-verify', - data: { - 'uuid': uuid, - 'cifNo': cifNo, - } - ); - if (response.statusCode == 200) { - final String message = response.data.toString().trim().toUpperCase(); - - if (message == "VERIFIED") { - return; // Success + Future simVerify(String uuid, String cifNo) async{ + + try{ + + final response = await _dio.post( + + '/api/sim-details-verify', + + data: { + + 'uuid': uuid, + + 'cifNo': cifNo, + + } + + ); + + if (response.statusCode == 200) { + + final String message = response.data.toString().toUpperCase(); + + if (message.contains("VERIFIED")) { + + return; // Success + + } else { + + throw AuthException(message); // Throw message received + + } + } else { - throw AuthException(message); // Throw message received + + throw AuthException('Verification Failed'); + } - } else { - throw AuthException('Verification Failed'); + + } on DioException catch (e) { + + if (kDebugMode) { + + print(e.toString()); + + } + + if (e.response?.statusCode == 401) { + + throw AuthException( + + e.response?.data['error'] ?? 'SOMETHING WENT WRONG'); + + } + + throw NetworkException('Network error during verification'); + } - } on DioException catch (e) { - if (kDebugMode) { - print(e.toString()); + + catch (e) { + + throw UnexpectedException( + + 'Unexpected error during verification: ${e.toString()}'); + } - if (e.response?.statusCode == 401) { - throw AuthException( - e.response?.data['error'] ?? 'SOMETHING WENT WRONG'); - } - throw NetworkException('Network error during verification'); + } - catch (e) { - throw UnexpectedException( - 'Unexpected error during verification: ${e.toString()}'); - } - } Future login(AuthCredentials credentials) async { try { diff --git a/lib/features/auth/screens/verification_screen.dart b/lib/features/auth/screens/verification_screen.dart index d297f15..460f8f2 100644 --- a/lib/features/auth/screens/verification_screen.dart +++ b/lib/features/auth/screens/verification_screen.dart @@ -104,7 +104,7 @@ class _VerificationScreenState extends State { } catch (e) { setState(() { - _statusMessage = " $e SIM verification failed. Please try again."; + _statusMessage = e.toString(); _isVerifying = false; _verificationFailed = true; });