isUploadOptionAvailable static method

bool isUploadOptionAvailable(
  1. KenumUploadOptions option
)

Check Upload options availability

Whether the upload option is configured or not.

Implementation

static bool isUploadOptionAvailable(KenumUploadOptions option) {
  final config = Config().config;

  // GITHUB
  final gitHub = config.uploadOptions.github;
  final isGitHubEnabled = gitHub.enabled;
  final isGitHubRepoProvided =
      gitHub.repo != null && gitHub.repo!.trim().isNotEmpty;
  final isGitHubRepoToken =
      gitHub.token != null && gitHub.token!.trim().isNotEmpty;

  // GOOGLE DRIVE
  final googleDrive = config.uploadOptions.googleDrive;
  final isGoogleDriveEnabled = googleDrive.enabled;
  final isGoogleDriveClientIdProvided =
      googleDrive.clientId != null && googleDrive.clientId!.trim().isNotEmpty;
  final isGoogleDriveClientSecretProvided =
      googleDrive.clientSecret != null &&
          googleDrive.clientSecret!.trim().isNotEmpty;

  switch (option) {
    case KenumUploadOptions.github:
      if (isGitHubEnabled && isGitHubRepoProvided && isGitHubRepoToken) {
        return true;
      }
      return false;
    case KenumUploadOptions.googleDrive:
      if (isGoogleDriveEnabled &&
          isGoogleDriveClientIdProvided &&
          isGoogleDriveClientSecretProvided) {
        return true;
      }
      return false;
    default:
      return false;
  }
}