import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/childvaccines/user_information_model.dart';
import '../base_service.dart';

class UserInformationService extends BaseService {
  List<List_UserInformationModel> userInformationModelList = List();
  Map<String, dynamic> body = Map();

  Future getUserInformationOrders() async {
    hasError = false;
    await getUser();
    body['CreatedBy'] = 102;
    body['EditedBy'] = 102;
    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_USERINFORMATION_REQUEST,
        onSuccess: (dynamic response, int statusCode) {
      userInformationModelList.clear();

      response['List_UserInformationModel_New'].forEach((vital) {
        userInformationModelList.add(List_UserInformationModel.fromJson(vital));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
  }
}
