RestApiClientImpl constructor

RestApiClientImpl({
  1. required RestApiClientOptions options,
  2. ExceptionOptions? exceptionOptions,
  3. LoggingOptions? loggingOptions,
  4. AuthOptions? authOptions,
  5. CacheOptions? cacheOptions,
  6. List<Interceptor> interceptors = const [],
})

Implementation

RestApiClientImpl({
  required RestApiClientOptions options,
  ExceptionOptions? exceptionOptions,
  LoggingOptions? loggingOptions,
  AuthOptions? authOptions,
  CacheOptions? cacheOptions,
  List<Interceptor> interceptors = const [],
}) {
  _options = options;
  _exceptionOptions = exceptionOptions ?? ExceptionOptions();
  _loggingOptions = loggingOptions ?? LoggingOptions();
  _authOptions = authOptions ?? AuthOptions();
  _cacheOptions = cacheOptions ?? CacheOptions();

  _dio = Dio(BaseOptions(baseUrl: _options.baseUrl));

  _dio.httpClientAdapter = getAdapter();

  exceptionHandler = ExceptionHandler(exceptionOptions: _exceptionOptions);

  authHandler = AuthHandler(
      dio: _dio,
      options: options,
      exceptionOptions: _exceptionOptions,
      authOptions: _authOptions,
      loggingOptions: _loggingOptions);

  cacheHandler = CacheHandler(
      loggingOptions: _loggingOptions, cacheOptions: _cacheOptions);

  _configureLogging();
  _addInterceptors(interceptors);
  _configureCertificateOverride();
}