import 'package:dio/dio.dart';
import 'package:injectable/injectable.dart';
import 'package:location/data/api/atmob_api.dart';
import 'package:location/data/consts/constants.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import '../data/consts/build_config.dart';

@module
abstract class NetworkModule {
  @singleton
  Dio createDefaultDio() {
    Dio dio = Dio(BaseOptions());
    dio.interceptors.add(PrettyDioLogger(
      requestHeader: true,
      requestBody: true,
      responseBody: true,
      responseHeader: false,
      error: true,
      compact: true,
      enabled: BuildConfig.isDebug,
    ));
    return dio;
  }

  @singleton
  AtmobApi provideAtmobApi(Dio dio) {
    return AtmobApi(dio, baseUrl: Constants.baseUrl);
  }
}
