import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_item.dart'; import 'package:diplomaticquarterapp/core/model/vaccine/vaccination_on_hand.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; import 'package:diplomaticquarterapp/core/model/vaccine/my_vaccine.dart'; class VaccineService extends BaseService { List _vaccineList = List(); List vaccinationItemList = List(); List vaccinationOnHandList = List(); List get vaccineList => _vaccineList; Future getMyVaccine() async { Map body = Map(); body['To'] = "0"; body['From'] = "0"; hasError = false; _vaccineList.clear(); await baseAppClient.post(GET_VACCINES, onSuccess: (dynamic response, int statusCode) { response['List_DoneVaccines'].forEach((item) { _vaccineList.add(VaccineModel.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } Future sendEmail() async { Map body = Map(); body['ListVaccines'] = vaccineList.map((v) => v.toJson()).toList(); body['To'] = user.emailAddress; body['DateofBirth'] = user.dateofBirth; body['PatientIditificationNum'] = user.patientIdentificationNo; body['PatientMobileNumber'] = user.mobileNumber; body['PatientName'] = user.firstName + " " + user.lastName; hasError = false; await baseAppClient.post(GET_VACCINES_EMAIL, onSuccess: (dynamic response, int statusCode) {}, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } Future getMyVaccinationItem() async { await baseAppClient.post(GET_VACCINATIONS_ITEMS, onSuccess: (dynamic response, int statusCode) { response['GetVaccinationsList'].forEach((item) { vaccinationItemList.add(VaccinationItem.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: Map()); } Future getMyVaccinationOnHand({String pItemCode}) async { Map body = Map(); body['P_ITEM_CODE'] = pItemCode; await baseAppClient.post(GET_VACCINATION_ONHAND, onSuccess: (dynamic response, int statusCode) { response['GetVaccinationOnHandList'].forEach((item) { vaccinationOnHandList.add(VaccinationOnHand.fromJson(item)); }); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } }