import 'package:driverapp/config/config.dart';
import 'package:driverapp/core/model/authentication/authenticated_user.dart';
import 'package:driverapp/core/model/authentication/login_request.dart';
import 'package:driverapp/core/service/base_service.dart';

class AuthenticationService extends BaseService {
  String selectedClinicName;
  bool isLogin = false;
  bool isLoading = true;
  AuthenticatedUser authenticatedUser;
  String token;

  AuthenticationService() {
//    getUserAuthentication();
  }

  login(LoginRequest loginRequest) async {
    hasError = false;
    try {
      await baseAppClient.post(LOGIN,
          onSuccess: (dynamic response, int statusCode) {
        authenticatedUser =
            AuthenticatedUser.fromJson(response['PatientER_DriverFile']);
        token = response['LogInTokenID'];
      }, onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      }, body: loginRequest.toJson());
    } catch (error) {
      hasError = true;
      super.error = error;
      throw error;
    }
  }
}
