Class GitHubHandler

java.lang.Object
javiergs.tulip.GitHubHandler

public class GitHubHandler extends Object
A utility class for interacting with public GitHub repositories using the GitHub REST API. Supports listing files in a folder and retrieving file contents.
Version:
1.0
Author:
Javier Gonzalez-Sanchez
  • Constructor Details

    • GitHubHandler

      public GitHubHandler(String owner, String repo)
      Constructor to initialize the GitHubHandler with a specific repository.
      Parameters:
      owner - the GitHub username or organization
      repo - the name of the repository
  • Method Details

    • listFiles

      public List<String> listFiles(String path) throws IOException
      Lists all file names in a given folder of a public GitHub repository.
      Parameters:
      path - the folder path inside the repository
      Returns:
      a list of file paths (relative to the root)
      Throws:
      IOException - if the API call fails
    • getFileContent

      public String getFileContent(String path) throws IOException
      Retrieves the raw content of a file in a public GitHub repository.
      Parameters:
      path - the full file path inside the repository
      Returns:
      the decoded content of the file as a String
      Throws:
      IOException - if the file cannot be retrieved or is not base64-encoded