From 45e868adbad8d4c1865b4da1ff978353c6cbb7a2 Mon Sep 17 00:00:00 2001 From: faizatflutter Date: Mon, 1 Sep 2025 15:55:21 +0300 Subject: [PATCH] pushed new API --- ios/Runner.xcodeproj/project.pbxproj | 14 +++- .../authentication/authentication_repo.dart | 37 +++------ .../authentication_view_model.dart | 13 ++-- ...ent_last_login_details_response_model.dart | 30 ++++---- .../models/select_device_by_imei.dart | 77 +++++++++++++++++++ 5 files changed, 121 insertions(+), 50 deletions(-) create mode 100644 lib/features/authentication/models/select_device_by_imei.dart diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index bac2157..dae81f2 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -279,10 +279,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Copy Pods Resources"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n"; @@ -296,10 +300,14 @@ inputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); + inputPaths = ( + ); name = "[CP] Embed Pods Frameworks"; outputFileListPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); + outputPaths = ( + ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; @@ -451,7 +459,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = 3A359E86ZF; + DEVELOPMENT_TEAM = ZB3P5B74MA; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.6; @@ -633,7 +641,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = 3A359E86ZF; + DEVELOPMENT_TEAM = ZB3P5B74MA; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.6; @@ -658,7 +666,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = 2; - DEVELOPMENT_TEAM = 3A359E86ZF; + DEVELOPMENT_TEAM = ZB3P5B74MA; ENABLE_BITCODE = NO; INFOPLIST_FILE = Runner/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 15.6; diff --git a/lib/features/authentication/authentication_repo.dart b/lib/features/authentication/authentication_repo.dart index 64bc2ca..a5e9ae3 100644 --- a/lib/features/authentication/authentication_repo.dart +++ b/lib/features/authentication/authentication_repo.dart @@ -1,12 +1,13 @@ - import 'package:dartz/dartz.dart'; import 'package:hmg_patient_app_new/core/api/api_client.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_exception.dart'; import 'package:hmg_patient_app_new/core/exceptions/api_failure.dart'; +import 'package:hmg_patient_app_new/features/authentication/models/select_device_by_imei.dart'; import 'package:hmg_patient_app_new/services/logger_service.dart'; +import 'package:http/http.dart'; abstract class AuthenticationRepo { - Future> signIn({required String phone, required String password}); + Future> selectDeviceByImei({required String deviceIMEI}); } class AuthenticationRepoImp implements AuthenticationRepo { @@ -16,28 +17,14 @@ class AuthenticationRepoImp implements AuthenticationRepo { AuthenticationRepoImp({required this.loggerService, required this.apiClient}); @override - Future> signIn({required String phone, required String password}) async { - try { - // Mock API call with delayed response - final result = await Future.delayed( - const Duration(seconds: 2), - () => { - 'success': true, - 'data': [ - { - 'id': '1', - 'name': 'Dr. Ahmed Hassan', - 'specialty': 'Cardiology', - 'experience': '10 years', - 'rating': 4.8, - 'image': 'https://example.com/doctor1.jpg' - }, - ] - } - ); + Future> selectDeviceByImei({required String deviceIMEI}) async { + final mapDevice = {"": deviceIMEI}; - if (result != null && result is Map && result['success'] != null && result['success'] != null && result['success'] != false) { - return Right(result); + final String apiUrl = "https://hmgwebservices.com/Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI" ; + try { + final Response result = await apiClient.postJsonForResponse(apiUrl, mapDevice); + if (result !=null) { + return Right(null); } else { loggerService.errorLogs(result.toString()); return Left(ServerFailure(result.toString())); @@ -54,6 +41,4 @@ class AuthenticationRepoImp implements AuthenticationRepo { return Left(ServerFailure(e.toString())); } } - - -} \ No newline at end of file +} diff --git a/lib/features/authentication/authentication_view_model.dart b/lib/features/authentication/authentication_view_model.dart index 434df16..5b45790 100644 --- a/lib/features/authentication/authentication_view_model.dart +++ b/lib/features/authentication/authentication_view_model.dart @@ -7,6 +7,8 @@ class AuthenticationViewModel extends ChangeNotifier { AuthenticationViewModel({required this.authenticationRepo}); + + Future signUp({ required String phone, required String password, @@ -14,13 +16,12 @@ class AuthenticationViewModel extends ChangeNotifier { Function(String)? onError, }) async { Utils.showLoading(); - final resultEither = await authenticationRepo.signIn( - phone: phone, - password: password, - ); + final String deviceIMEI = + "cIkkB7h7Q7uoFkC4Qv82xG:APA91bEb53Z9XzqymCIctaLxCoMX6bm9fuKlWILQ59uUqfwhCoD42AOP1-jWGB1WYd9BVN5PT2pUUFxrT07vcNg1KH9OH39mrPgCl0m21XVIgWrzNnCkufg"; - if (resultEither.isLeft()) { + final resultEither = await authenticationRepo.selectDeviceByImei(deviceIMEI: deviceIMEI); + if (resultEither.isLeft()) { } @@ -37,7 +38,7 @@ class AuthenticationViewModel extends ChangeNotifier { if (onError != null) onError(failure.message); }, (data) { - Utils.hideLoading(); + notifyListeners(); if (onSuccess != null) onSuccess(data); }, diff --git a/lib/features/authentication/models/get_patient_last_login_details_response_model.dart b/lib/features/authentication/models/get_patient_last_login_details_response_model.dart index a14da5e..ce48dd4 100644 --- a/lib/features/authentication/models/get_patient_last_login_details_response_model.dart +++ b/lib/features/authentication/models/get_patient_last_login_details_response_model.dart @@ -48,21 +48,21 @@ class GetPatientLastLoginDetailsResponseModel { } Map toJson() { - final Map data = new Map(); - data['ID'] = this.iD; - data['IMEI'] = this.iMEI; - data['LogInType'] = this.logInType; - data['PatientID'] = this.patientID; - data['OutSA'] = this.outSA; - data['Mobile'] = this.mobile; - data['IdentificationNo'] = this.identificationNo; - data['Name'] = this.name; - data['NameN'] = this.nameN; - data['CreatedOn'] = this.createdOn; - data['EditedOn'] = this.editedOn; - data['BiometricEnabled'] = this.biometricEnabled; - data['PatientType'] = this.patientType; - data['PreferredLanguage'] = this.preferredLanguage; + final Map data = {}; + data['ID'] = iD; + data['IMEI'] = iMEI; + data['LogInType'] = logInType; + data['PatientID'] = patientID; + data['OutSA'] = outSA; + data['Mobile'] = mobile; + data['IdentificationNo'] = identificationNo; + data['Name'] = name; + data['NameN'] = nameN; + data['CreatedOn'] = createdOn; + data['EditedOn'] = editedOn; + data['BiometricEnabled'] = biometricEnabled; + data['PatientType'] = patientType; + data['PreferredLanguage'] = preferredLanguage; return data; } } diff --git a/lib/features/authentication/models/select_device_by_imei.dart b/lib/features/authentication/models/select_device_by_imei.dart new file mode 100644 index 0000000..2ab669e --- /dev/null +++ b/lib/features/authentication/models/select_device_by_imei.dart @@ -0,0 +1,77 @@ +// To parse this JSON data, do +// +// final selectDeviceByImeiRespModel = selectDeviceByImeiRespModelFromJson(jsonString); + +import 'dart:convert'; + +Map selectDeviceByImeiRespModelFromJson(String str) => Map.from(json.decode(str)).map((k, v) => MapEntry(k, v)); + +String selectDeviceByImeiRespModelToJson(Map data) => json.encode(Map.from(data).map((k, v) => MapEntry(k, v))); + +class SelectDeviceByImeiRespModelElement { + int id; + String imei; + int logInType; + int patientId; + bool outSa; + String mobile; + String identificationNo; + String name; + String nameN; + String createdOn; + String editedOn; + bool biometricEnabled; + int patientType; + int preferredLanguage; + + SelectDeviceByImeiRespModelElement({ + required this.id, + required this.imei, + required this.logInType, + required this.patientId, + required this.outSa, + required this.mobile, + required this.identificationNo, + required this.name, + required this.nameN, + required this.createdOn, + required this.editedOn, + required this.biometricEnabled, + required this.patientType, + required this.preferredLanguage, + }); + + factory SelectDeviceByImeiRespModelElement.fromJson(Map json) => SelectDeviceByImeiRespModelElement( + id: json["ID"], + imei: json["IMEI"], + logInType: json["LogInType"], + patientId: json["PatientID"], + outSa: json["OutSA"], + mobile: json["Mobile"], + identificationNo: json["IdentificationNo"], + name: json["Name"], + nameN: json["NameN"], + createdOn: json["CreatedOn"], + editedOn: json["EditedOn"], + biometricEnabled: json["BiometricEnabled"], + patientType: json["PatientType"], + preferredLanguage: json["PreferredLanguage"], + ); + + Map toJson() => { + "ID": id, + "IMEI": imei, + "LogInType": logInType, + "PatientID": patientId, + "OutSA": outSa, + "Mobile": mobile, + "IdentificationNo": identificationNo, + "Name": name, + "NameN": nameN, + "CreatedOn": createdOn, + "EditedOn": editedOn, + "BiometricEnabled": biometricEnabled, + "PatientType": patientType, + "PreferredLanguage": preferredLanguage, + }; +}