import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
import 'package:rasadyar_core/core.dart';

import '../di/chicken_di.dart';
import 'constant.dart';

class DioRemoteManager {
  DioRemote? _currentClient;
  ApiEnvironment? _currentEnv;

  Future<DioRemote> setEnvironment([
    ApiEnvironment env = ApiEnvironment.dam,
  ]) async {
    if (_currentEnv != env) {
      _currentClient = DioRemote(baseUrl: env.baseUrl);
      await _currentClient?.init();
      _currentEnv = env;
    }
    return _currentClient!;
  }

  DioRemote get currentClient {
    if (_currentClient == null) {
      throw Exception('Call setEnvironment() before accessing DioRemote.');
    }

    return _currentClient!;
  }

  ApiEnvironment? get currentEnv => _currentEnv;
}


