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.
diplomatic-quarter/lib/core/service/feedback/feedback_service.dart

109 lines
4.1 KiB
Dart

import 'dart:io';
import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/feedback/COC_items.dart';
import 'package:diplomaticquarterapp/core/model/feedback/request_insert_coc_item.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/Appointments/AppoimentAllHistoryResultList.dart';
import 'package:diplomaticquarterapp/uitl/utils.dart';
class FeedbackService extends BaseService {
List<COCItem> cOCItemList = List();
RequestInsertCOCItem _requestInsertCOCItem = RequestInsertCOCItem();
List<AppoitmentAllHistoryResultList> appointHistoryList = List();
Future sendCOCItem(
{String title,
String details,
String cOCTypeName,
String attachment,
AppoitmentAllHistoryResultList appointHistory}) async {
hasError = false;
var languageID =
await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'ar');
_requestInsertCOCItem.attachment = attachment;
_requestInsertCOCItem.title = title;
_requestInsertCOCItem.details = details;
_requestInsertCOCItem.cOCTypeName = cOCTypeName;
_requestInsertCOCItem.formTypeID = cOCTypeName;
_requestInsertCOCItem.mobileNo =
"966" + Utils.getPhoneNumberWithoutZero(user.mobileNumber);
_requestInsertCOCItem.isUserLoggedIn = true;
_requestInsertCOCItem.projectID = user.projectID;
_requestInsertCOCItem.patientName = user.firstName + " " + user.lastName;
_requestInsertCOCItem.fileName = "";
_requestInsertCOCItem.appVersion = VERSION_ID;
_requestInsertCOCItem.uILanguage =
languageID; //TODO Change it to be dynamic
_requestInsertCOCItem.browserInfo = Platform.localHostname;
_requestInsertCOCItem.deviceInfo = Platform.localHostname;
_requestInsertCOCItem.resolution = "400x847";
_requestInsertCOCItem.projectID = 0;
_requestInsertCOCItem.identificationNo =
int.parse(user.patientIdentificationNo);
if (BASE_URL.contains('uat')) {
_requestInsertCOCItem.forDemo = true;
}
final Map<String, dynamic> body = _requestInsertCOCItem.toJson();
if (appointHistory != null) {
body['AppoinmentNo'] = appointHistory.appointmentNo;
body['AppointmentDate'] = appointHistory.appointmentDate;
body['ClinicID'] = appointHistory.clinicID;
body['ClinicName'] = appointHistory.clinicName;
body['DoctorID'] = appointHistory.doctorID;
body['DoctorName'] = appointHistory.doctorNameObj;
body['ProjectName'] = appointHistory.projectName;
}
await baseAppClient
.post(SEND_FEEDBACK, onSuccess: (dynamic response, int statusCode) {},
onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getStatusCOC() async {
hasError = false;
Map<String, dynamic> body = new Map<String, dynamic>();
body['IdentificationNo'] = user.patientIdentificationNo;
body['MobileNo'] =
"966" + Utils.getPhoneNumberWithoutZero(user.mobileNumber);
body['Searching_type'] = '1';
if (BASE_URL.contains('uat')) {
body['ForDemo'] = true;
}
await baseAppClient.post(GET_STATUS_FOR_COCO,
onSuccess: (dynamic response, int statusCode) {
cOCItemList = [];
response['ListCOCItems'].forEach((cOC) {
cOCItemList.add(COCItem.fromJson(cOC));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
Future getPatentAppointmentHistory() async {
hasError = false;
Map<String, dynamic> body = new Map<String, dynamic>();
body['IsComingFromCOC'] = true;
baseAppClient.post(GET_PATIENT_AppointmentHistory,
onSuccess: (dynamic response, int statusCode) {
appointHistoryList = [];
response['AppoimentAllHistoryResultList'].forEach((appoint) {
appointHistoryList
.add(AppoitmentAllHistoryResultList.fromJson(appoint));
});
}, onFailure: (String error, int statusCode) {
hasError = true;
super.error = error;
}, body: body);
}
}