import 'package:softplayer_dart_proto/environments/environments_v1.pbenum.dart';
import 'package:softplayer_web/helpers/providers/hetzner.dart';

abstract class Provider {
  String getServerLocation(String serverLocation);
  String rawServerLocation(String serverLocation);
  String defaultLocation();

  String getProviderName();
  String rawProviderName();
}

class ProviderHelper {
  String getServerType(String serverType) {
    if (serverType == ServerType.SERVER_TYPE_STARTER.toString()) {
      return "Starter";
    } else if (serverType == ServerType.SERVER_TYPE_REGULAR.toString()) {
      return "Regular";
    } else if (serverType == ServerType.SERVER_TYPE_PLUS.toString()) {
      return "Plus";
    } else if (serverType == ServerType.SERVER_TYPE_PRO.toString()) {
      return "Pro";
    } else if (serverType == ServerType.SERVER_TYPE_CUSTOM.toString()) {
      throw 'Custom server type is not yet supported';
    } else {
      throw 'Unknown server type';
    }
  }

  String rawServerType(String serverType) {
    if (serverType == "Starter") {
      return ServerType.SERVER_TYPE_STARTER.toString();
    } else if (serverType == "Regular") {
      return ServerType.SERVER_TYPE_REGULAR.toString();
    } else if (serverType == "Plus") {
      return ServerType.SERVER_TYPE_PLUS.toString();
    } else if (serverType == "Pro") {
      return ServerType.SERVER_TYPE_PRO.toString();
    } else {
      throw 'Unknown server type';
    }
  }

  Hetzner getProvider(String provider) {
    switch (provider) {
      case "hetzner" || "PROVIDER_HETZNER":
        return Hetzner();
      default:
        throw "unknown prodiver";
    }
  }
}
