|
|
|
|
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/activation_code_for_verification_screen_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/check_activation_code_request_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/models/doctor/doctor_profile_model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/profile_req_Model.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/models/doctor/user_model.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 = {};
|
|
|
|
|
|
|
|
|
|
List<DoctorProfileModel> _doctorProfilesList = [];
|
|
|
|
|
|
|
|
|
|
List<DoctorProfileModel> get doctorProfilesList => _doctorProfilesList;
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
_checkActivationCodeForDoctorAppRes =
|
|
|
|
|
CheckActivationCodeForDoctorAppResponseModel.fromJson(response);
|
|
|
|
|
}, 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;
|
|
|
|
|
// insertIMEIDetailsModel.tokenID = "@dm!n";
|
|
|
|
|
_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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future getDoctorProfileBasedOnClinic(ProfileReqModel profileReqModel) async {
|
|
|
|
|
hasError = false;
|
|
|
|
|
try {
|
|
|
|
|
await baseAppClient.post(GET_DOC_PROFILES,
|
|
|
|
|
onSuccess: (dynamic response, int statusCode) {
|
|
|
|
|
_doctorProfilesList.clear();
|
|
|
|
|
response['DoctorProfileList'].forEach((v) {
|
|
|
|
|
_doctorProfilesList.add(DoctorProfileModel.fromJson(v));
|
|
|
|
|
});
|
|
|
|
|
}, onFailure: (String error, int statusCode) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}, body: profileReqModel.toJson());
|
|
|
|
|
} catch (error) {
|
|
|
|
|
hasError = true;
|
|
|
|
|
super.error = error;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|