|
|
|
|
import 'package:doctor_app_flutter/config/config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/activation_Code_req_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/check_activation_code_for_doctor_app_response_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/imei_details.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/insert_imei_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/new_login_information_response_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/send_activation_code_for_doctor_app_response_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/service/base/base_service.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/viewModel/doctor_profile_view_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/activation_code_for_verification_screen_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/model/auth/check_activation_code_request_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/clinic_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/user_model.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
class AuthenticationService extends BaseService {
|
|
|
|
|
List<GetIMEIDetailsModel> _imeiDetails = [];
|
|
|
|
|
List<GetIMEIDetailsModel> get dashboardItemsList => _imeiDetails;
|
|
|
|
|
NewLoginInformationModel _loginInfo = NewLoginInformationModel();
|
|
|
|
|
NewLoginInformationModel get loginInfo => _loginInfo;
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel _activationCodeVerificationScreenRes = SendActivationCodeForDoctorAppResponseModel();
|
|
|
|
|
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel get activationCodeVerificationScreenRes => _activationCodeVerificationScreenRes;
|
|
|
|
|
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel _activationCodeForDoctorAppRes = SendActivationCodeForDoctorAppResponseModel();
|
|
|
|
|
|
|
|
|
|
SendActivationCodeForDoctorAppResponseModel get activationCodeForDoctorAppRes => _activationCodeForDoctorAppRes;
|
|
|
|
|
CheckActivationCodeForDoctorAppResponseModel _checkActivationCodeForDoctorAppRes = CheckActivationCodeForDoctorAppResponseModel();
|
|
|
|
|
|
|
|
|
|
CheckActivationCodeForDoctorAppResponseModel get checkActivationCodeForDoctorAppRes => _checkActivationCodeForDoctorAppRes;
|
|
|
|
|
Map<String, dynamic> _insertDeviceImeiRes = {};
|
|
|
|
|
|
|
|
|
|
Future selectDeviceImei(imei) async {
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(SELECT_DEVICE_IMEI,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_imeiDetails = [];
|
|
|
|
|
response['List_DoctorDeviceDetails'].forEach((v) {
|
|
|
|
|
_imeiDetails.add(GetIMEIDetailsModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: {"IMEI": imei, "TokenID": "@dm!n"});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future login(UserModel userInfo) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
_loginInfo = NewLoginInformationModel();
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(LOGIN_URL,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_loginInfo = NewLoginInformationModel.fromJson(response);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: userInfo.toJson());
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future sendActivationCodeVerificationScreen(ActivationCodeForVerificationScreenModel activationCodeModel) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
_activationCodeVerificationScreenRes = SendActivationCodeForDoctorAppResponseModel();
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_VERIFICATION_SCREEN,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_activationCodeVerificationScreenRes = SendActivationCodeForDoctorAppResponseModel.fromJson(response);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: activationCodeModel.toJson());
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future sendActivationCodeForDoctorApp(ActivationCodeModel activationCodeModel)async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
_activationCodeForDoctorAppRes = SendActivationCodeForDoctorAppResponseModel();
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(SEND_ACTIVATION_CODE_FOR_DOCTOR_APP,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_activationCodeForDoctorAppRes = SendActivationCodeForDoctorAppResponseModel.fromJson(response);
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: activationCodeModel.toJson());
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future checkActivationCodeForDoctorApp(CheckActivationCodeRequestModel checkActivationCodeRequestModel)async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
_checkActivationCodeForDoctorAppRes = CheckActivationCodeForDoctorAppResponseModel();
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(CHECK_ACTIVATION_CODE_FOR_DOCTOR_APP,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
// TODO improve the logic here
|
|
|
|
|
Provider.of<DoctorProfileViewModel>(AppGlobal.CONTEX, listen: false).doctorsClinicList.clear();
|
|
|
|
|
_checkActivationCodeForDoctorAppRes = CheckActivationCodeForDoctorAppResponseModel.fromJson(response);
|
|
|
|
|
Provider.of<DoctorProfileViewModel>(AppGlobal.CONTEX, listen: false).selectedClinicName =
|
|
|
|
|
ClinicModel.fromJson(response['List_DoctorsClinic'][0]).clinicName;
|
|
|
|
|
|
|
|
|
|
response['List_DoctorsClinic'].forEach((v) {
|
|
|
|
|
Provider.of<DoctorProfileViewModel>(AppGlobal.CONTEX, listen: false).doctorsClinicList.add(new ClinicModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: checkActivationCodeRequestModel.toJson());
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future insertDeviceImei(InsertIMEIDetailsModel insertIMEIDetailsModel)async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
_insertDeviceImeiRes = {};
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(INSERT_DEVICE_IMEI,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_insertDeviceImeiRes = response;
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: insertIMEIDetailsModel.toJson());
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|