
import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/config/shared_pref_kay.dart';
import 'package:hmg_patient_app/core/model/childvaccines/List_BabyInformationModel.dart';
import 'package:hmg_patient_app/core/model/childvaccines/user_information_model.dart';

import '../base_service.dart';

class ChildVaccinesService extends BaseService {
  List<List_BabyInformationModel> babyInformationModelList =[];
  List<List_UserInformationModel> userInformationModelList =[];
  int userID = 0;

  Future getAllBabyInformationOrders() async {
    Map<String, dynamic> body = Map();
    hasError = false;
    body['isDentalAllowedBackend'] = false;
    body['IsLogin'] = true;
    body['UserID'] = userID;
    await baseAppClient.post(GET_BABY_BY_USER_ID,
        onSuccess: (dynamic response, int statusCode) {
      babyInformationModelList.clear();
      response['List_BabyInformationModel'].forEach((vital) {
        babyInformationModelList.add(List_BabyInformationModel.fromJson(vital));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
  }

  Future getNewUserOrders() async {
    Map<String, dynamic> body = Map();
    hasError = false;
    await getUser();
    body['CreatedBy'] = 102;
    body['EditedBy'] = 102;
    body['UserID'] = userID;
    body['AlertBy'] = 2;
    body['EmailAddress'] = user.emailAddress;
    body['IsLogin'] = true;
    body['LogInTokenID'] = await sharedPref.getString(TOKEN);
    body['MobileNumber'] = user.mobileNumber;
    body['NationalID'] = user.nationalityID;
    body['ZipCode'] = user.zipCode;
    body['isDentalAllowedBackend'] = false;

    await baseAppClient.post(GET_NEW_USER_REQUEST,
        onSuccess: (dynamic response, int statusCode) {
      userID = response['UserID'];
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
  }
}
