|
|
|
|
@ -24,29 +24,20 @@ enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
|
|
|
|
|
AppSharedPreferences sharedPref = new AppSharedPreferences();
|
|
|
|
|
AppGlobal appGlobal = new AppGlobal();
|
|
|
|
|
|
|
|
|
|
const String INSERT_DEVICE_IMEI =
|
|
|
|
|
'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI';
|
|
|
|
|
const String SELECT_DEVICE_IMEI =
|
|
|
|
|
'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI';
|
|
|
|
|
const String CHECK_PATIENT_AUTH =
|
|
|
|
|
'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
const String INSERT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_INSERTDeviceIMEI';
|
|
|
|
|
const String SELECT_DEVICE_IMEI = 'Services/Patients.svc/REST/Patient_SELECTDeviceIMEIbyIMEI';
|
|
|
|
|
const String CHECK_PATIENT_AUTH = 'Services/Authentication.svc/REST/CheckPatientAuthentication';
|
|
|
|
|
const GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo';
|
|
|
|
|
const SEND_ACTIVATION_CODE =
|
|
|
|
|
'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType';
|
|
|
|
|
const CHECK_ACTIVATION_CODE =
|
|
|
|
|
'Services/Authentication.svc/REST/CheckActivationCode';
|
|
|
|
|
const FORGOT_PASSWORD =
|
|
|
|
|
'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
|
|
|
|
|
const CHECK_PATIENT_FOR_REGISTRATION =
|
|
|
|
|
"Services/Authentication.svc/REST/CheckPatientForRegisteration";
|
|
|
|
|
const SEND_ACTIVATION_CODE = 'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType';
|
|
|
|
|
const CHECK_ACTIVATION_CODE = 'Services/Authentication.svc/REST/CheckActivationCode';
|
|
|
|
|
const FORGOT_PASSWORD = 'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
|
|
|
|
|
const CHECK_PATIENT_FOR_REGISTRATION = "Services/Authentication.svc/REST/CheckPatientForRegisteration";
|
|
|
|
|
|
|
|
|
|
const CHECK_USER_STATUS = "Services/NHIC.svc/REST/GetPatientInfo";
|
|
|
|
|
const REGISTER_USER = 'Services/Authentication.svc/REST/PatientRegistration';
|
|
|
|
|
const LOGGED_IN_USER_URL =
|
|
|
|
|
'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo';
|
|
|
|
|
const LOGGED_IN_USER_URL = 'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo';
|
|
|
|
|
|
|
|
|
|
const FORGOT_PATIENT_ID =
|
|
|
|
|
'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
|
|
|
|
|
const FORGOT_PATIENT_ID = 'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
|
|
|
|
|
const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
|
|
|
|
|
const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate';
|
|
|
|
|
const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo';
|
|
|
|
|
@ -55,8 +46,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
bool isLogin = false;
|
|
|
|
|
bool isLoading = true;
|
|
|
|
|
dynamic authenticatedUser;
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject =
|
|
|
|
|
locator<AuthenticatedUserObject>();
|
|
|
|
|
AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();
|
|
|
|
|
|
|
|
|
|
AuthProvider() {
|
|
|
|
|
getUserAuthentication();
|
|
|
|
|
@ -110,17 +100,14 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
var lastLogin = lstLogin; //await sharedPref.getInt(
|
|
|
|
|
// LAST_LOGIN); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); //this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false);
|
|
|
|
|
|
|
|
|
|
var request =
|
|
|
|
|
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
|
|
|
|
|
var request = AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
|
|
|
|
|
var newRequest = INSERTDeviceIMEIRequest();
|
|
|
|
|
|
|
|
|
|
var imei = await sharedPref.getString(PUSH_TOKEN);
|
|
|
|
|
// if (!request.) {
|
|
|
|
|
newRequest.iMEI = imei; //imei!=null ? imei : '';
|
|
|
|
|
newRequest.firstName =
|
|
|
|
|
request.firstName ?? "" + " " + request.lastName ?? "";
|
|
|
|
|
newRequest.firstNameN =
|
|
|
|
|
request.firstNameN ?? "" + " " + request.lastNameN ?? "";
|
|
|
|
|
newRequest.firstName = request.firstName ?? "" + " " + request.lastName ?? "";
|
|
|
|
|
newRequest.firstNameN = request.firstNameN ?? "" + " " + request.lastNameN ?? "";
|
|
|
|
|
newRequest.lastNameN = request.lastNameN ?? "";
|
|
|
|
|
newRequest.outSA = request.outSA == 1 ? true : false;
|
|
|
|
|
newRequest.biometricEnabled = false;
|
|
|
|
|
@ -135,8 +122,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
newRequest.tokenID = await sharedPref.getString(TOKEN);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
await new BaseAppClient().post(INSERT_DEVICE_IMEI,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(INSERT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
@ -153,10 +139,8 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
Map<String, dynamic> request = {};
|
|
|
|
|
request['IMEI'] = imei;
|
|
|
|
|
await new BaseAppClient().post(SELECT_DEVICE_IMEI,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = SelectDeviceIMEIRES.fromJson(
|
|
|
|
|
response['Patient_SELECTDeviceIMEIbyIMEIList'][0]);
|
|
|
|
|
await new BaseAppClient().post(SELECT_DEVICE_IMEI, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = SelectDeviceIMEIRES.fromJson(response['Patient_SELECTDeviceIMEIbyIMEIList'][0]);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
}, body: request);
|
|
|
|
|
@ -166,8 +150,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<dynamic> checkPatientAuthentication(
|
|
|
|
|
CheckPatientAuthenticationReq request) async {
|
|
|
|
|
Future<dynamic> checkPatientAuthentication(CheckPatientAuthenticationReq request) async {
|
|
|
|
|
request.versionID = VERSION_ID;
|
|
|
|
|
request.channel = CHANNEL;
|
|
|
|
|
request.iPAdress = IP_ADDRESS;
|
|
|
|
|
@ -176,8 +159,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
request.patientOutSA = request.zipCode == '966' ? 0 : 1;
|
|
|
|
|
try {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await new BaseAppClient().post(CHECK_PATIENT_AUTH,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(CHECK_PATIENT_AUTH, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
@ -198,10 +180,10 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
request.deviceTypeID = DeviceTypeID;
|
|
|
|
|
request.patientOutSA = request.zipCode == '966' ? 0 : 1;
|
|
|
|
|
request.isDentalAllowedBackend = false;
|
|
|
|
|
|
|
|
|
|
// request.patientTypeID = request.patientType;
|
|
|
|
|
// request.patientType = request.patientType;
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await new BaseAppClient().post(GET_MOBILE_INFO,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(GET_MOBILE_INFO, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
@ -220,8 +202,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
request.isDentalAllowedBackend = false;
|
|
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
await new BaseAppClient().post(SEND_ACTIVATION_CODE,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(SEND_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
authenticatedUser = CheckActivationCode.fromJson(localRes);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
@ -243,14 +224,12 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1;
|
|
|
|
|
neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true;
|
|
|
|
|
neRequest.isDentalAllowedBackend = false;
|
|
|
|
|
neRequest.deviceToken = null;
|
|
|
|
|
neRequest.forRegisteration =
|
|
|
|
|
neRequest.isRegister != null ? neRequest.isRegister : false;
|
|
|
|
|
// neRequest.deviceToken = null;
|
|
|
|
|
neRequest.forRegisteration = neRequest.isRegister != null ? neRequest.isRegister : false;
|
|
|
|
|
neRequest.isRegister = false;
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(CHECK_ACTIVATION_CODE,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(CHECK_ACTIVATION_CODE, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -270,8 +249,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
return authenticatedUser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<dynamic> checkPatientForRegisteration(
|
|
|
|
|
CheckPatientForRegistration request) async {
|
|
|
|
|
Future<dynamic> checkPatientForRegisteration(CheckPatientForRegistration request) async {
|
|
|
|
|
request.versionID = VERSION_ID;
|
|
|
|
|
request.channel = CHANNEL;
|
|
|
|
|
request.iPAdress = IP_ADDRESS;
|
|
|
|
|
@ -282,8 +260,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
// request.tokenID = '';
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(CHECK_PATIENT_FOR_REGISTRATION,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(CHECK_PATIENT_FOR_REGISTRATION, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -306,8 +283,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
// request.tokenID = '';
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(CHECK_USER_STATUS,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(CHECK_USER_STATUS, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -332,8 +308,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
// request.tokenID = '';
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(REGISTER_USER,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(REGISTER_USER, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -345,30 +320,26 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future registeredAuthenticatedUser(
|
|
|
|
|
AuthenticatedUser user, deviceToken, lat, long) async {
|
|
|
|
|
Future registeredAuthenticatedUser(AuthenticatedUser user, deviceToken, lat, long) async {
|
|
|
|
|
var request = new RegisteredAuthenticatedUserRequest();
|
|
|
|
|
request.deviceToken = deviceToken;
|
|
|
|
|
request.voipToken =
|
|
|
|
|
""; //this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false);
|
|
|
|
|
request.voipToken = ""; //this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false);
|
|
|
|
|
request.deviceType = DeviceTypeID.toString();
|
|
|
|
|
request.patientMobileNumber = '0' + user.mobileNumber;
|
|
|
|
|
request.patientMobileNumber = user.mobileNumber[0] == '0' ? user.mobileNumber : '0' + user.mobileNumber;
|
|
|
|
|
request.nationalID = user.patientIdentificationNo;
|
|
|
|
|
request.gender = user.gender;
|
|
|
|
|
request.patientID = user.patientID;
|
|
|
|
|
request.patientOutSA = user.outSA;
|
|
|
|
|
request.loginType = await sharedPref.getInt(LAST_LOGIN) != null
|
|
|
|
|
? await sharedPref.getInt(LAST_LOGIN)
|
|
|
|
|
: 1;
|
|
|
|
|
request.loginType = await sharedPref.getInt(LAST_LOGIN) != null ? await sharedPref.getInt(LAST_LOGIN) : 1;
|
|
|
|
|
request.mACAddress = '00:00:00:00:00:00';
|
|
|
|
|
request.latitude = lat;
|
|
|
|
|
request.longitude = long;
|
|
|
|
|
request.languageID = int.parse(user.preferredLanguage);
|
|
|
|
|
request.patientTypeID = 2;
|
|
|
|
|
request.patientTypeID = user.patientType;
|
|
|
|
|
request.patientType = user.patientType;
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(LOGGED_IN_USER_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(LOGGED_IN_USER_URL, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -394,8 +365,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
|
|
|
|
|
await new BaseAppClient().post(FORGOT_PATIENT_ID,
|
|
|
|
|
onSuccess: (response, statusCode) async {
|
|
|
|
|
await new BaseAppClient().post(FORGOT_PATIENT_ID, onSuccess: (response, statusCode) async {
|
|
|
|
|
localRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
throw error;
|
|
|
|
|
@ -416,8 +386,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(FORGOT_PASSWORD,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(FORGOT_PASSWORD, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -439,12 +408,10 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
request['generalid'] = GENERAL_ID;
|
|
|
|
|
request['LanguageID'] = LANGUAGE_ID;
|
|
|
|
|
request['DeviceTypeID'] = DeviceTypeID;
|
|
|
|
|
request["PatientTypeID"] = 1;
|
|
|
|
|
request["PatientType"] = 1;
|
|
|
|
|
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(DASHBOARD,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(DASHBOARD, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -461,8 +428,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
getSettings() async {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(PROFILE_SETTING,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(PROFILE_SETTING, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
@ -479,8 +445,7 @@ class AuthProvider with ChangeNotifier {
|
|
|
|
|
Future saveSettings(request) async {
|
|
|
|
|
dynamic localRes;
|
|
|
|
|
try {
|
|
|
|
|
await new BaseAppClient().post(SAVE_SETTING,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
await new BaseAppClient().post(SAVE_SETTING, onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
localRes = response; //CheckActivationCode.fromJson();
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
localRes = error;
|
|
|
|
|
|