import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/locator.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';

import 'AuthenticatedUserObject.dart';
import 'client/base_app_client.dart';

class BaseService {
  String error;
  bool hasError = false;
  BaseAppClient baseAppClient = BaseAppClient();
  AuthenticatedUser user = new AuthenticatedUser();

  AuthenticatedUserObject authenticatedUserObject = locator<AuthenticatedUserObject>();

  AppSharedPreferences sharedPref = AppSharedPreferences();

  BaseService() {
    authenticatedUserObject.getUser();
    user = authenticatedUserObject.user;
   // getUser();
  }

  getUser() async {
    // if (user==null) {
      var userData = await sharedPref.getObject(USER_PROFILE);
      if (userData != null) user = AuthenticatedUser.fromJson(userData);
    // }
  }
}
