DartStreamMachineClient constructor

DartStreamMachineClient({
  1. required DartStreamConfig config,
  2. required String clientId,
  3. required String clientSecret,
  4. String? tenantId,
  5. required String projectId,
  6. Client? httpClient,
  7. DateTime now()?,
})

Implementation

DartStreamMachineClient({
  required DartStreamConfig config,
  required this.clientId,
  required String clientSecret,
  this.tenantId,
  required this.projectId,
  http.Client? httpClient,
  DateTime Function()? now,
}) : _secret = clientSecret,
     _http = httpClient ?? http.Client(),
     _ownsHttp = httpClient == null,
     _config = config,
     _now = now ?? DateTime.now {
  if (clientId.trim().isEmpty ||
      clientSecret.isEmpty ||
      (tenantId != null && tenantId!.trim().isEmpty) ||
      projectId.trim().isEmpty) {
    throw ArgumentError(
      'Machine credentials require a client and project.',
    );
  }
  final url = config.billingBaseUrl;
  if (url.scheme != 'https' &&
      !(url.scheme == 'http' &&
          ['localhost', '127.0.0.1', '::1'].contains(url.host))) {
    throw ArgumentError(
      'Machine credential exchange requires HTTPS (or local loopback).',
    );
  }
  client = DartStreamClient(config: config, httpClient: _http);
}