You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_Patient_App/lib/services/authentication/auth_provider.dart

647 lines
23 KiB
Dart

import 'dart:io';
6 years ago
import 'package:diplomaticquarterapp/config/config.dart';
6 years ago
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/service/AuthenticatedUserObject.dart';
import 'package:diplomaticquarterapp/core/service/client/base_app_client.dart';
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
import 'package:diplomaticquarterapp/main.dart';
import 'package:diplomaticquarterapp/models/Appointments/toDoCountProviderModel.dart';
6 years ago
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_request_register.dart';
6 years ago
import 'package:diplomaticquarterapp/models/Authentication/check_activation_code_response.dart';
import 'package:diplomaticquarterapp/models/Authentication/check_paitent_authentication_req.dart';
6 years ago
import 'package:diplomaticquarterapp/models/Authentication/check_user_status_req.dart';
import 'package:diplomaticquarterapp/models/Authentication/checkpatient_for_registration.dart';
6 years ago
import 'package:diplomaticquarterapp/models/Authentication/insert_device_imei_request.dart';
import 'package:diplomaticquarterapp/models/Authentication/register_user_requet.dart';
import 'package:diplomaticquarterapp/models/Authentication/registered_authenticated_user_req.dart';
import 'package:diplomaticquarterapp/models/Authentication/select_device_imei_res.dart';
import 'package:diplomaticquarterapp/models/Request.dart';
import 'package:diplomaticquarterapp/routes.dart';
6 years ago
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:flutter/cupertino.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import '../../locator.dart';
6 years ago
// SharedPreferences sharedPref = new SharedPreferences();
enum APP_STATUS { LOADING, UNAUTHENTICATED, AUTHENTICATED }
2 years ago
AppSharedPreferences sharedPref = AppSharedPreferences();
AppGlobal appGlobal = AppGlobal();
6 years ago
2 years ago
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';
6 years ago
const GET_MOBILE_INFO = 'Services/Authentication.svc/REST/GetMobileLoginInfo';
2 years ago
const SEND_ACTIVATION_CODE =
'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationType';
2 years ago
const SEND_ACTIVATION_CODE_REGISTER =
'Services/Authentication.svc/REST/SendActivationCodebyOTPNotificationTypeForRegistration';
const CHECK_ACTIVATION_CODE =
'Services/Authentication.svc/REST/CheckActivationCode';
const CHECK_ACTIVATION_CODE_REGISTER =
'Services/Authentication.svc/REST/CheckActivationCodeForRegistration';
2 years ago
const FORGOT_PASSWORD =
'Services/Authentication.svc/REST/CheckActivationCodeForSendFileNo';
const CHECK_PATIENT_FOR_REGISTRATION =
"Services/Authentication.svc/REST/CheckPatientForRegisteration";
6 years ago
6 years ago
const CHECK_USER_STATUS = "Services/NHIC.svc/REST/GetPatientInfo";
const REGISTER_USER = 'Services/Authentication.svc/REST/PatientRegistration';
2 years ago
const LOGGED_IN_USER_URL =
'Services/MobileNotifications.svc/REST/Insert_PatientMobileDeviceInfo';
6 years ago
2 years ago
const FORGOT_PATIENT_ID =
'Services/Authentication.svc/REST/SendPatientIDSMSByMobileNumber';
const DASHBOARD = 'Services/Patients.svc/REST/PatientDashboard';
5 years ago
const PROFILE_SETTING = 'Services/Patients.svc/REST/GetPateintInfoForUpdate';
const SAVE_SETTING = 'Services/Patients.svc/REST/UpdatePateintInfo';
5 years ago
2 years ago
const DEACTIVATE_ACCOUNT =
'Services/Patients.svc/REST/PatientAppleActivation_InsertUpdate';
6 years ago
class AuthProvider with ChangeNotifier {
bool isLogin = false;
bool isLoading = true;
dynamic authenticatedUser;
2 years ago
AuthenticatedUserObject authenticatedUserObject =
locator<AuthenticatedUserObject>();
var languageID;
6 years ago
AuthProvider() {
getUserAuthentication();
}
void getUserAuthentication() async {
Map profile = await sharedPref.getObject(USER_PROFILE) ?? Map();
languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
6 years ago
if (profile != null) {
isLoading = false;
isLogin = true;
} else {
isLoading = false;
isLogin = false;
}
notifyListeners();
}
APP_STATUS get stutas {
if (isLoading) {
return APP_STATUS.LOADING;
} else {
if (this.isLogin) {
return APP_STATUS.AUTHENTICATED;
} else {
return APP_STATUS.UNAUTHENTICATED;
}
}
}
// Future<dynamic> login(UserModel userInfo) async {
// try {
// dynamic localRes;
// await BaseAppClient.post(LOGIN_URL,
// onSuccess: (dynamic response, int statusCode) {
// localRes = response;
// }, onFailure: (String error, int statusCode) {
// throw error;
// }, body: userInfo.toJson());
// return Future.value(localRes);
// } catch (error) {
// print(error);
// throw error;
// }
// }
6 years ago
Future<dynamic> insertDeviceImei(lstLogin) async {
6 years ago
try {
dynamic localRes;
6 years ago
var lastLogin = lstLogin; //await sharedPref.getInt(
// LAST_LOGIN); //this.cs.sharedService.getStorage(AuthenticationService.LAST_LOGIN); //this.cs.sharedService.getSharedData(AuthenticationService.LAST_LOGIN, false);
6 years ago
2 years ago
var request =
AuthenticatedUser.fromJson(await sharedPref.getObject(USER_PROFILE));
6 years ago
var newRequest = INSERTDeviceIMEIRequest();
6 years ago
var imei = await sharedPref.getString(PUSH_TOKEN);
// if (!request.) {
5 years ago
newRequest.iMEI = imei; //imei!=null ? imei : '';
2 years ago
newRequest.firstName =
request.firstName ?? "" + " " + request.lastName! ?? "";
newRequest.firstNameN =
request.firstNameN ?? "" + " " + request.lastNameN! ?? "";
6 years ago
newRequest.lastNameN = request.lastNameN ?? "";
newRequest.outSA = request.outSA == 1 ? true : false;
newRequest.biometricEnabled = false;
newRequest.preferredLanguage = int.parse(request.preferredLanguage!) ?? 1;
6 years ago
newRequest.logInTypeID = lastLogin ?? 1;
newRequest.patientID = request.patientID;
newRequest.mobileNo = request.mobileNumber;
newRequest.identificationNo = request.patientIdentificationNo;
newRequest.patientIdentificationNo = request.patientIdentificationNo;
newRequest.patientType = request.patientType;
newRequest.setupID = request.setupID;
newRequest.tokenID = await sharedPref.getString(TOKEN);
6 years ago
// }
6 years ago
2 years ago
await new BaseAppClient().post(INSERT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) {
6 years ago
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
6 years ago
}, body: newRequest.toJson());
6 years ago
return Future.value(localRes);
} catch (error) {
print(error);
throw error;
}
}
2 years ago
Future<SelectDeviceIMEIRES?> selectDeviceImei(imei,
{int languageID = 1}) async {
6 years ago
try {
2 years ago
// SelectDeviceIMEIRES? localRes;
print(imei);
6 years ago
Map<String, dynamic> request = {};
request['IMEI'] = imei;
2 years ago
request['LanguageID'] = languageID;
2 years ago
await BaseAppClient().post(SELECT_DEVICE_IMEI,
onSuccess: (dynamic response, int statusCode) async {
2 years ago
// localRes = Map();
print(
"Here response: ${response['Patient_SELECTDeviceIMEIbyIMEIList'][0]}");
if (response['Patient_SELECTDeviceIMEIbyIMEIList'][0] != null) {
2 years ago
sharedPref.setObject(
IMEI_USER_DATA,
SelectDeviceIMEIRES.fromJson(
response['Patient_SELECTDeviceIMEIbyIMEIList'][0]));
return SelectDeviceIMEIRES.fromJson(
Merge branch 'development_v3.3' of http://34.17.52.79/Haroon6138/diplomatic-quarter into dev_v3.13.6 # Conflicts: # lib/config/config.dart # lib/core/model/labs/patient_lab_orders.dart # lib/core/model/labs/request_patient_lab_special_result.dart # lib/core/model/labs/request_send_lab_report_email.dart # lib/core/model/radiology/final_radiology.dart # lib/core/model/radiology/request_send_rad_report_email.dart # lib/core/model/rate/appoitment_rated.dart # lib/core/service/client/base_app_client.dart # lib/core/service/medical/labs_service.dart # lib/core/service/medical/radiology_service.dart # lib/core/viewModels/medical/labs_view_model.dart # lib/core/viewModels/medical/radiology_view_model.dart # lib/models/Authentication/check_activation_code_request.dart # lib/models/FamilyFiles/GetAllSharedRecordsByStatusReq.dart # lib/pages/BookAppointment/BookSuccess.dart # lib/pages/BookAppointment/QRCode.dart # lib/pages/DrawerPages/family/my-family.dart # lib/pages/DrawerPages/notifications/notification_details_page.dart # lib/pages/MyAppointments/AppointmentDetails.dart # lib/pages/MyAppointments/MyAppointments.dart # lib/pages/MyAppointments/widgets/AppointmentActions.dart # lib/pages/ToDoList/ToDo.dart # lib/pages/landing/landing_page.dart # lib/pages/livecare/widgets/clinic_list.dart # lib/pages/login/confirm-login.dart # lib/pages/login/login.dart # lib/pages/medical/labs/laboratory_result_page.dart # lib/pages/medical/radiology/radiology_details_page.dart # lib/services/authentication/auth_provider.dart # lib/splashPage.dart # lib/uitl/push-notification-handler.dart # lib/widgets/drawer/app_drawer_widget.dart
2 years ago
response['Patient_SELECTDeviceIMEIbyIMEIList'][0]);
2 years ago
} else {
print("ELSE TRIGERRED!!!!!!!!!");
}
2 years ago
// 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);
}, onFailure: (String error, int statusCode) {
print("in the failure with : $error and $statusCode");
}, body: request);
2 years ago
} catch (error) {
2 years ago
print("in the error");
// return Future.error(error);
6 years ago
}
}
6 years ago
2 years ago
Future<dynamic> checkPatientAuthentication(
CheckPatientAuthenticationReq request) async {
6 years ago
request.versionID = VERSION_ID;
request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS;
request.generalid = GENERAL_ID;
request.languageID = (languageID == 'ar' ? 1 : 2);
2 years ago
request.patientOutSA =
(request.zipCode == '966' || request.zipCode == '+966') ? 0 : 1;
5 years ago
try {
dynamic localRes;
2 years ago
await new BaseAppClient().post(CHECK_PATIENT_AUTH,
onSuccess: (dynamic response, int statusCode) {
5 years ago
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request.toJson());
return Future.value(localRes);
} catch (error) {
6 years ago
throw error;
5 years ago
//throw error;
}
6 years ago
}
Future<dynamic> getLoginInfo(request) async {
request.versionID = VERSION_ID;
request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS;
request.generalid = GENERAL_ID;
request.languageID = (languageID == 'ar' ? 1 : 2);
request.deviceTypeID = Platform.isIOS ? 1 : 2;
request.patientOutSA = request.zipCode == '966' ? 0 : 1;
request.isDentalAllowedBackend = false;
// request.patientTypeID = request.patientType;
// request.patientType = request.patientType;
5 years ago
dynamic localRes;
2 years ago
await new BaseAppClient().post(GET_MOBILE_INFO,
onSuccess: (dynamic response, int statusCode) {
5 years ago
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
5 years ago
}, body: request.toJson());
return Future.value(localRes);
}
Future<dynamic> sendActivationCode(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 = request.zipCode == '966' ? 0 : 1;
request.isDentalAllowedBackend = false;
5 years ago
dynamic localRes;
2 years ago
await new BaseAppClient().post(SEND_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) {
5 years ago
localRes = response;
authenticatedUser = CheckActivationCode.fromJson(localRes);
}, onFailure: (String error, int statusCode) {
throw error;
5 years ago
}, body: request.toJson());
return Future.value(localRes);
}
6 years ago
Future<dynamic> sendActivationCodeRegister(request) async {
request.versionID = VERSION_ID;
request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS;
request.generalid = GENERAL_ID;
request.languageID = (languageID == 'ar' ? 1 : 2);
request.deviceTypeID = Platform.isIOS ? 1 : 2;
request.patientOutSA = request.zipCode == '966' ? 0 : 1;
request.isDentalAllowedBackend = false;
dynamic localRes;
2 years ago
await new BaseAppClient().post(SEND_ACTIVATION_CODE_REGISTER,
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> checkActivationCode(request, [value]) async {
6 years ago
var neRequest = CheckActivationCodeReq.fromJson(request);
6 years ago
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;
6 years ago
neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1;
5 years ago
neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true;
6 years ago
neRequest.isDentalAllowedBackend = false;
// neRequest.deviceToken = null;
2 years ago
neRequest.forRegisteration =
neRequest.isRegister != null ? neRequest.isRegister : false;
neRequest.isRegister = false;
6 years ago
dynamic localRes;
6 years ago
try {
2 years ago
await new BaseAppClient().post(CHECK_ACTIVATION_CODE,
onSuccess: (dynamic response, int statusCode) {
6 years ago
localRes = response; //CheckActivationCode.fromJson();
6 years ago
}, onFailure: (String error, int statusCode) {
6 years ago
localRes = error;
return Future.value(error);
// throw error;
6 years ago
}, body: neRequest.toJson());
return Future.value(localRes);
} catch (error) {
throw localRes;
}
}
Future<dynamic> checkActivationCodeRegister(request, [value]) async {
var neRequest = CheckActivationCodeRegisterReq.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;
// request.languageID = (languageID == 'ar' ? 1 : 2);
3 years ago
neRequest.deviceTypeID = Platform.isIOS ? 1 : 2;
neRequest.patientOutSA = neRequest.zipCode == '966' ? 0 : 1;
neRequest.projectOutSA = neRequest.zipCode == '966' ? false : true;
neRequest.isDentalAllowedBackend = false;
// neRequest.deviceToken = null;
2 years ago
neRequest.forRegisteration =
neRequest.isRegister != null ? neRequest.isRegister : false;
neRequest.isRegister = false;
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(CHECK_ACTIVATION_CODE_REGISTER,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: neRequest.toJson());
// sharedPref.setString(BLOOD_TYPE, localRes['PatientBloodType']);
6 years ago
return Future.value(localRes);
} catch (error) {
5 years ago
throw localRes;
6 years ago
//return Future.value(error);
6 years ago
}
}
AuthenticatedUser getAuthenticatedUser() {
this.isLogin = true;
return authenticatedUser;
}
6 years ago
2 years ago
Future<dynamic> checkPatientForRegisteration(
CheckPatientForRegistration request) async {
6 years ago
request.versionID = VERSION_ID;
request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS;
request.generalid = GENERAL_ID;
request.languageID = (languageID == 'ar' ? 1 : 2);
request.deviceTypeID = Platform.isIOS ? 1 : 2;
6 years ago
request.isRegister = false;
// request.tokenID = '';
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(CHECK_PATIENT_FOR_REGISTRATION,
onSuccess: (dynamic response, int statusCode) {
6 years ago
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: request.toJson());
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future<dynamic> checkUserStatus(CheckUserStatusRequest request) async {
request.versionID = VERSION_ID;
request.channel = CHANNEL;
request.iPAdress = IP_ADDRESS;
request.generalid = GENERAL_ID;
request.languageID = (languageID == 'ar' ? 1 : 2);
request.deviceTypeID = Platform.isIOS ? 1 : 2;
6 years ago
// request.tokenID = '';
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(CHECK_USER_STATUS,
onSuccess: (dynamic response, int statusCode) {
6 years ago
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: request.toJson());
return Future.value(localRes);
} catch (error) {
throw error;
}
}
5 years ago
Future<dynamic> registerUser(request) async {
request['VersionID'] = VERSION_ID;
request['Channel'] = CHANNEL;
request['IPAdress'] = IP_ADDRESS;
request['Generalid'] = GENERAL_ID;
request['DeviceTypeID'] = Platform.isIOS ? 1 : 2;
request['LanguageID'] = (languageID == 'ar' ? 1 : 2);
request['LogInTokenID'] = await sharedPref.getString(LOGIN_TOKEN_ID);
var nhic = await sharedPref.getObject(NHIC_DATA);
5 years ago
var requestN = RegisterUserRequest.fromJson(request);
requestN.patientOutSA = requestN.patientobject!.patientOutSA!;
final DateFormat dateFormat = DateFormat('MM/dd/yyyy');
final DateFormat dateFormat2 = DateFormat('dd/MM/yyyy');
if (nhic != null) {
2 years ago
requestN.dob = nhic['IsHijri']
? nhic['DateOfBirth']
: dateFormat2.format(dateFormat.parse(nhic['DateOfBirth']));
requestN.isHijri = nhic['IsHijri'] ? 1 : 0;
requestN.healthId = requestN.patientobject!.eHealthIDField!;
}
requestN.zipCode = requestN.patientOutSA == 1 ? '971' : '966';
5 years ago
await sharedPref.remove(USER_PROFILE);
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(REGISTER_USER,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
5 years ago
}, body: requestN.toJson());
return Future.value(localRes);
} catch (error) {
throw error;
}
}
2 years ago
Future registeredAuthenticatedUser(
AuthenticatedUser user, deviceToken, lat, long) async {
var request = new RegisteredAuthenticatedUserRequest();
request.deviceToken = deviceToken;
2 years ago
request.voipToken =
""; //this.cs.sharedService.getSharedData(AuthenticationService.APNS_TOKEN, false);
request.deviceType = Platform.isIOS ? "1" : "2";
2 years ago
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;
2 years ago
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 = user.patientType;
request.patientType = user.patientType;
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(LOGGED_IN_USER_URL,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: request.toJson());
return Future.value(localRes);
} catch (error) {
throw error;
}
}
5 years ago
Future<Map> sendPatientIDSMS(mobileNo, zipCode, context) async {
Map<String, dynamic> request;
5 years ago
Request req = appGlobal.getPublicRequest();
request = {
5 years ago
"PatientOutSA": zipCode == '+966' ? 0 : 1,
"PatientMobileNumber": mobileNo,
"SearchType": 2,
5 years ago
"ZipCode": zipCode,
"DeviceTypeID": req.DeviceTypeID,
};
dynamic localRes;
2 years ago
await new BaseAppClient().post(FORGOT_PATIENT_ID,
onSuccess: (response, statusCode) async {
localRes = response;
}, onFailure: (String error, int statusCode) {
throw error;
}, body: request);
return Future.value(localRes);
}
5 years ago
Future<dynamic> forgotPasswordActivation(request, [value]) async {
request['VersionID'] = VERSION_ID;
request['Channel'] = CHANNEL;
request['IPAdress'] = IP_ADDRESS;
request['generalid'] = GENERAL_ID;
request['DeviceTypeID'] = Platform.isIOS ? 1 : 2;
request['LanguageID'] = (languageID == 'ar' ? 1 : 2);
5 years ago
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(FORGOT_PASSWORD,
onSuccess: (dynamic response, int statusCode) {
5 years ago
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
//return Future.value(error);
}
}
Future<dynamic> getDashboard() async {
Map<String, dynamic> request = {};
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(DASHBOARD,
onSuccess: (dynamic response, int statusCode) {
localRes = response; //CheckActivationCode.fromJson();
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
// throw error;
}, body: request);
return Future.value(localRes);
} catch (error) {
throw error;
//return Future.value(error);
}
}
5 years ago
5 years ago
getSettings() async {
5 years ago
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(PROFILE_SETTING,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
5 years ago
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: {});
5 years ago
return Future.value(localRes);
} catch (error) {
throw error;
}
}
5 years ago
Future saveSettings(request) async {
5 years ago
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(SAVE_SETTING,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
5 years ago
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: request);
5 years ago
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future deactivateAccount(request, bool isLogin) async {
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(DEACTIVATE_ACCOUNT,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: request);
if (!isLogin) logout();
return Future.value(localRes);
} catch (error) {
throw error;
}
}
Future activateAccount(request) async {
dynamic localRes;
try {
2 years ago
await new BaseAppClient().post(DEACTIVATE_ACCOUNT,
onSuccess: (dynamic response, int statusCode) {
localRes = response;
}, onFailure: (String error, int statusCode) {
localRes = error;
return Future.value(error);
}, body: request);
logout();
return Future.value(localRes);
} catch (error) {
throw error;
}
}
logout() async {
await sharedPref.remove(LOGIN_TOKEN_ID);
await sharedPref.remove(PHARMACY_CUSTOMER_ID);
await authenticatedUserObject.getUser();
2 years ago
Provider.of<ProjectViewModel>(AppGlobal.context, listen: false).isLogin =
false;
var model =
Provider.of<ToDoCountProviderModel>(AppGlobal.context, listen: false);
2 years ago
model.setState(0, 0, false, null);
Navigator.of(AppGlobal.context).pushReplacementNamed(HOME);
}
6 years ago
}