import 'package:diplomaticquarterapp/config/config.dart'; import 'package:diplomaticquarterapp/config/shared_pref_kay.dart'; import 'package:diplomaticquarterapp/core/model/pharmacies/LacumAccountInformation.dart'; import 'package:diplomaticquarterapp/core/service/base_service.dart'; class LacumService extends BaseService{ bool isFinished = true; bool hasError = false; String errorMsg = ''; String successMsg = ''; LacumAccountInformation lacumInformation; LacumAccountInformation lacumGroupInformation; Future getLacumAccountInformation() async { hasError = false; super.error = ""; Map body = Map(); body['IdentificationNo'] = user.patientIdentificationNo; try { await baseAppClient.post(GET_LACUM_ACCOUNT_INFORMATION, onSuccess: (response, statusCode) async { lacumInformation = LacumAccountInformation.fromJson(response); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } catch (error) { throw error; } } Future getLacumGroupInformation() async { hasError = false; super.error = ""; Map body = Map(); body['IdentificationNo'] = user.patientIdentificationNo; body['AccountNumber'] = "${lacumInformation.yahalaAccountNo}"; body['IsDetailsRequired'] = true; try { await baseAppClient.post(GET_LACUM_GROUP_INFORMATION, onSuccess: (response, statusCode) async { lacumGroupInformation = LacumAccountInformation.fromJson(response); }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } catch (error) { throw error; } } Future makeAccountActivate() async { hasError = false; super.error = ""; int yahalaAccountNo = lacumInformation.yahalaAccountNo; Map body = Map(); body['CreatedBy'] = 103; body['YahalaAccountNumber'] = yahalaAccountNo; try { await baseAppClient.post(LACUM_ACCOUNT_ACTIVATE, onSuccess: (response, statusCode) async { // lacumInformation = LacumAccountInformation.fromJson(response); // lacumInformation.yahalaAccountNo = yahalaAccountNo; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } catch (error) { throw error; } } Future makeAccountDeactivate() async { hasError = false; super.error = ""; int yahalaAccountNo = lacumInformation.yahalaAccountNo; Map body = Map(); body['CreatedBy'] = 103; body['YahalaAccountNumber'] = yahalaAccountNo; try { await baseAppClient.post(LACUM_ACCOUNT_DEACTIVATE, onSuccess: (response, statusCode) async { // lacumInformation = LacumAccountInformation.fromJson(response); // lacumInformation.yahalaAccountNo = yahalaAccountNo; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } catch (error) { throw error; } } Future createLakumAccount(String name, String phone, int accountID, String patientIdentificationID, var prefLang) async { hasError = false; super.error = ""; if(prefLang == null){ var languageID = await sharedPref.getStringWithDefaultValue(APP_LANGUAGE, 'en'); prefLang = languageID == 'ar' ? 1 : 2; } Map body = Map(); body['PrefLang'] = prefLang; body['AccountID'] = accountID; body['FullName'] = name; body['MobileNo'] = phone; body['PatientIdentificationID'] = patientIdentificationID; body['PatientID'] = user.patientID; try { await baseAppClient.post(CREATE_LAKUM_ACCOUNT, onSuccess: (response, statusCode) async { successMsg = LacumAccountInformation.fromJson(response).message; }, onFailure: (String error, int statusCode) { hasError = true; super.error = error; }, body: body); } catch (error) { throw error; } } }