OpenToolClient constructor

OpenToolClient({
  1. bool? isSSL,
  2. required String toolHost,
  3. required int toolPort,
  4. String? toolApiKey,
})

Implementation

OpenToolClient({
  bool? isSSL,
  required String toolHost,
  required int toolPort,
  this.toolApiKey,
}) {
  if (isSSL != null) this.isSSL = isSSL;
  if (toolHost.isNotEmpty) this.host = toolHost;
  if (toolPort > 0) this.port = toolPort;

  String protocol = this.isSSL ? 'https' : 'http';
  String baseUrl = '$protocol://${this.host}:${this.port}${this.prefix}';

  Map<String, String> headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    if (toolApiKey != null && toolApiKey!.isNotEmpty)
      'Authorization': 'Bearer $toolApiKey',
  };

  dio = Dio(BaseOptions(baseUrl: baseUrl, headers: headers));
}