|
|
|
|
@ -34,13 +34,17 @@ AppSharedPreferences sharedPref = AppSharedPreferences();
|
|
|
|
|
AppGlobal appGlobal = AppGlobal();
|
|
|
|
|
|
|
|
|
|
const String INSERT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI';
|
|
|
|
|
const INSERT_DEVICE_IMEI_OTHERS ='Services/Patients.svc/REST/Patient_INSERTDeviceIMEI_Others';
|
|
|
|
|
const String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI';
|
|
|
|
|
const String CHECK_PATIENT_AUTH = 'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
const String CHECK_PATIENT_AUTH_OTHERS = 'Services/Authentication.svc/REST/CheckPatientAuthentication_Others';
|
|
|
|
|
const GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo';
|
|
|
|
|
const SEND_ACTIVATION_CODE = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType';
|
|
|
|
|
const SEND_ACTIVATION_CODE_OTHERS = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType_Others';
|
|
|
|
|
|
|
|
|
|
const SEND_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration';
|
|
|
|
|
const CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCode';
|
|
|
|
|
const CHECK_ACTIVATION_CODE_OTHERS = 'Services/Authentication.svc/REST/CheckActivationCode_Others';
|
|
|
|
|
const CHECK_ACTIVATION_CODE_REGISTER = 'Services/Authentication.svc/REST/CheckActivationCodeForRegistration';
|
|
|
|
|
|
|
|
|
|
const FORGOT_PASSWORD = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
|
|
|
|
|
@ -111,7 +115,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Future<dynamic> insertDeviceImei(lstLogin) async {
|
|
|
|
|
Future<dynamic> insertDeviceImei(lstLogin,{ bool isForOthers = false}) async {
|
|
|
|
|
try {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
var lastLogin = lstLogin; //await sharedPref.getInt(
|
|
|
|
|
@ -137,9 +141,8 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
newRequest.patientType = request.patientType;
|
|
|
|
|
newRequest.setupID = request.setupID;
|
|
|
|
|
newRequest.tokenID = await sharedPref.getString(TOKEN);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
await new BaseAppClient().post(INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(isForOthers ? INSERT_DEVICE_IMEI_OTHERS : INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
@ -196,7 +199,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
request.patientOutSA = (request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1;
|
|
|
|
|
try {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await new BaseAppClient().post(CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post( request.zipCode =='0' ? CHECK_PATIENT_AUTH_OTHERS : CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
@ -208,6 +211,27 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// New function for Others country authentication
|
|
|
|
|
Future<dynamic> checkPatientAuthenticationOthers(CheckPatientAuthenticationReq request) async {
|
|
|
|
|
request.versionID = VERSION_ID;
|
|
|
|
|
request.channel = CHANNEL;
|
|
|
|
|
request.iPAdress = IP_ADDRESS;
|
|
|
|
|
request.generalid = GENERAL_ID;
|
|
|
|
|
request.languageID = (languageID == 'ar' ? 1 : 2);
|
|
|
|
|
request.patientOutSA = 1; // Always set to 1 for Others (outside KSA/UAE)
|
|
|
|
|
try {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await new BaseAppClient().post(CHECK_PATIENT_AUTH_OTHERS, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
}, body: request.toJson());
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<dynamic> getLoginInfo(request) async {
|
|
|
|
|
request.versionID = VERSION_ID;
|
|
|
|
|
request.channel = CHANNEL;
|
|
|
|
|
@ -249,6 +273,28 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// New method for Others country activation code
|
|
|
|
|
Future<dynamic> sendActivationCodeOthers(request) async {
|
|
|
|
|
request.versionID = VERSION_ID;
|
|
|
|
|
request.channel = CHANNEL;
|
|
|
|
|
request.iPAdress = IP_ADDRESS;
|
|
|
|
|
request.generalid = GENERAL_ID;
|
|
|
|
|
// request.languageID = (languageID == 'ar' ? 1 : 2);
|
|
|
|
|
request.languageID = 2;
|
|
|
|
|
request.deviceTypeID = Platform.isIOS ? 1 : 2;
|
|
|
|
|
request.patientOutSA = 1; // Always 1 for Others (outside KSA/UAE)
|
|
|
|
|
request.isDentalAllowedBackend = false;
|
|
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await new BaseAppClient().post(SEND_ACTIVATION_CODE_OTHERS, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
authenticatedUser = CheckActivationCode.fromJson(localRes);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
}, body: request.toJson());
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<dynamic> sendActivationCodeRegister(request) async {
|
|
|
|
|
request.versionID = VERSION_ID;
|
|
|
|
|
request.channel = CHANNEL;
|
|
|
|
|
@ -282,6 +328,8 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1;
|
|
|
|
|
neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true;
|
|
|
|
|
neRequest.isDentalAllowedBackend = false;
|
|
|
|
|
// neRequest.zipCode ='966'; //hardcoded for testing
|
|
|
|
|
// request.languageID = (languageID == 'ar' ? 1 : 2)
|
|
|
|
|
// neRequest.deviceToken = null;
|
|
|
|
|
neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false;
|
|
|
|
|
neRequest.isRegister = false;
|
|
|
|
|
@ -300,6 +348,35 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<dynamic> checkActivationCodeOthers(request, [value]) async {
|
|
|
|
|
var neRequest = CheckActivationCodeReq.fromJson(request);
|
|
|
|
|
|
|
|
|
|
neRequest.activationCode = value ?? "0000";
|
|
|
|
|
neRequest.isSilentLogin = value != null ? false : true;
|
|
|
|
|
neRequest.versionID = VERSION_ID;
|
|
|
|
|
neRequest.channel = CHANNEL;
|
|
|
|
|
neRequest.iPAdress = IP_ADDRESS;
|
|
|
|
|
neRequest.generalid = GENERAL_ID;
|
|
|
|
|
neRequest.deviceTypeID = Platform.isIOS ? 1 : 2;
|
|
|
|
|
neRequest.patientOutSA = 1; // Always 1 for Others (outside KSA/UAE)
|
|
|
|
|
neRequest.projectOutSA = true; // Always true for Others
|
|
|
|
|
neRequest.isDentalAllowedBackend = false;
|
|
|
|
|
neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false;
|
|
|
|
|
neRequest.isRegister = false;
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(CHECK_ACTIVATION_CODE_OTHERS, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
return Future.value(error);
|
|
|
|
|
}, body: neRequest.toJson());
|
|
|
|
|
return Future.value(localRes);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw localRes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<dynamic> checkActivationCodeRegister(request, [value]) async {
|
|
|
|
|
var neRequest = CheckActivationCodeRegisterReq.fromJson(request);
|
|
|
|
|
|
|
|
|
|
@ -574,8 +651,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
// {
|
|
|
|
|
// "ID": 12,
|
|
|
|
|
// "ServiceName": "Precriptions",
|
|
|
|
|
// "Previlege": true,
|
|
|
|
|
// "Region": null
|
|
|
|
|
// "Previlege": true,// "Region": null
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "ID": 13,
|
|
|
|
|
|