Project constructor

Project(
  1. Completer completer, {
  2. String? username,
  3. String? project,
  4. String? token,
  5. String? configFile,
})

Implementation

Project(this.completer,
    {this.username, this.project, this.token, this.configFile}) {
  // Use username, project and token values if the 3 provided
  if (this.username != null || this.project != null || this.token != null) {
    if (this.username != null && this.project != null && this.token != null) {
      this.config =
          HopConfig(username: username, project: project, token: token);
      completer.complete(this.config);
      return;
    } else {
      throw InvalidConfig(
          "If you provide one of [username, project, token], you need to provide the 3 of them");
    }
  }

  HopConfig.fromFile(configFile).then((HopConfig config) {
    this.config = config;
    completer.complete(this.config);
  }).catchError((error) {
    completer.completeError(error);
  });
}