import 'package:dio/dio.dart';
import 'package:get_it/get_it.dart';

import 'src/network/dio_client.dart';
import 'src/env/env_contract.dart';
import 'src/api/questia_api.dart';
import 'src/repositories/questia_repository_impl.dart';
import 'src/repositories/questia_repository.dart';

export 'src/repositories/questia_repository.dart';

final getIt = GetIt.instance;

Future<void> configureDependencies(EnvConfig env, {bool log = false}) async {
  getIt.registerLazySingleton<Dio>(
    () => buildDioClient(
      baseUrl: env.apiBaseUrl,
      origin: env.apiOrigin,
      // apiKey: env.apiKey,
      log: log,
    ),
  );
  getIt.registerLazySingleton<QuestiaApi>(() => QuestiaApi(getIt<Dio>()));
  getIt.registerLazySingleton<QuestiaRepository>(
    () => QuestiaRepositoryImpl(getIt<QuestiaApi>()),
  );
}
