CDFApiClient constructor

CDFApiClient({
  1. String? project,
  2. String? token,
  3. String? apikey,
  4. String baseUrl = 'https://api.cognitedata.com',
  5. Level logLevel = Level.warning,
  6. HttpClientAdapter? httpAdapter,
})

Implementation

CDFApiClient(
    {this.project,
    this.token,
    this.apikey,
    this.baseUrl = 'https://api.cognitedata.com',
    this.logLevel = Level.warning,
    this.httpAdapter}) {
  this._apiUrl = this.baseUrl + '/api/v1/projects/' + this.project!;
  _history = [];
  if (this.httpAdapter != null) {
    _dio.httpClientAdapter = httpAdapter!;
  } else {
    throw CDFApiClientHttpAdapterException();
  }
  if (this.apikey?.length == 0) {
    this.apikey = null;
  }
  if (this.token?.length == 0) {
    this.token = null;
  }
  _dio.options.baseUrl = this._apiUrl!;
  _dio.interceptors.add(_CustomInterceptor(apikey, token, _history));
  _dio.options.receiveTimeout = 15000;
  _log = Logger(
      level: logLevel,
      // Use _MyLogPrinter if you want to force logging also in release mode.
      // It also gets rid of the extra formatting.
      printer: _MyLogPrinter(),
      output: null);
  _dio.interceptors.add(_CustomLogInterceptor(log: _log));
}