2025-05-14 11:44:46 +03:30
|
|
|
import 'package:rasadyar_auth/data/repositories/auth_repository_imp.dart';
|
2025-05-14 09:42:44 +03:30
|
|
|
import 'package:rasadyar_core/core.dart';
|
|
|
|
|
|
|
|
|
|
import '../di/auth_di.dart';
|
|
|
|
|
import 'constant.dart';
|
|
|
|
|
|
2025-07-12 17:06:29 +03:30
|
|
|
/*
|
2025-05-14 09:42:44 +03:30
|
|
|
class DioRemoteManager {
|
|
|
|
|
DioRemote? _currentClient;
|
|
|
|
|
ApiEnvironment? _currentEnv;
|
|
|
|
|
|
2025-07-12 17:06:29 +03:30
|
|
|
Future<DioRemote> setEnvironment([ApiEnvironment env = ApiEnvironment.dam]) async {
|
2025-05-14 09:42:44 +03:30
|
|
|
if (_currentEnv != env) {
|
2025-07-12 17:06:29 +03:30
|
|
|
_currentClient = DioRemote(
|
|
|
|
|
baseUrl: env.baseUrl,
|
|
|
|
|
interceptors: AppInterceptor(
|
|
|
|
|
refreshTokenCallback: () async{
|
|
|
|
|
return null;
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
);
|
2025-05-14 15:01:03 +03:30
|
|
|
await _currentClient?.init();
|
2025-05-14 09:42:44 +03:30
|
|
|
_currentEnv = env;
|
|
|
|
|
}
|
|
|
|
|
return _currentClient!;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DioRemote get currentClient {
|
|
|
|
|
if (_currentClient == null) {
|
|
|
|
|
throw Exception('Call setEnvironment() before accessing DioRemote.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return _currentClient!;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ApiEnvironment? get currentEnv => _currentEnv;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future<void> switchAuthEnvironment(ApiEnvironment env) async {
|
|
|
|
|
final manager = diAuth.get<DioRemoteManager>();
|
|
|
|
|
|
2025-05-14 15:01:03 +03:30
|
|
|
final dioRemote = await manager.setEnvironment(env);
|
2025-05-14 09:42:44 +03:30
|
|
|
|
|
|
|
|
if (diAuth.isRegistered<AuthRepositoryImpl>()) {
|
2025-05-14 15:01:03 +03:30
|
|
|
await diAuth.unregister<AuthRepositoryImpl>();
|
2025-05-14 09:42:44 +03:30
|
|
|
}
|
|
|
|
|
|
2025-07-12 17:06:29 +03:30
|
|
|
diAuth.registerLazySingleton<AuthRepositoryImpl>(() => AuthRepositoryImpl(dioRemote));
|
2025-05-14 09:42:44 +03:30
|
|
|
}
|
2025-07-12 17:06:29 +03:30
|
|
|
*/
|