private JSONObject getCommit()

in java/gradle/src/main/java/korosuke613/callApi/GitHub.java [12:27]


    private JSONObject getCommit(String owner, String repo, String ref) {
        var client = HttpClient.newHttpClient();
        var request = HttpRequest.newBuilder()
                .uri(URI.create("https://api.github.com/repos/" + owner + "/" + repo + "/commits/" + ref))
                .header("Accept", "application/vnd.github.v3+json")
                .build();

        HttpResponse<String> response = null;
        try {
            response = client.send(request, HttpResponse.BodyHandlers.ofString());
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }

        return new JSONObject(response.body());
    }