use of com.jcabi.github.RtGithub in project jcabi-github by jcabi.
the class Main method main.
/**
* Main entry point.
* @param args Command line arguments
*/
public static void main(final String[] args) throws Exception {
final Github github = new RtGithub();
final JsonResponse resp = github.entry().uri().path("/search/repositories").queryParam("q", "java").back().fetch().as(JsonResponse.class);
final List<JsonObject> items = resp.json().readObject().getJsonArray("items").getValuesAs(JsonObject.class);
for (final JsonObject item : items) {
System.out.println(String.format("repository found: %s", item.get("full_name").toString()));
}
}
use of com.jcabi.github.RtGithub in project jcabi-github by jcabi.
the class SampleTest method fetchesLabelsFromGithub.
/**
* Fetches labels from Github.
* @throws Exception If fails
*/
@Test
public void fetchesLabelsFromGithub() throws Exception {
final Github github = new RtGithub();
final Repo repo = github.repos().get(new Coordinates.Simple("jcabi/jcabi-github"));
MatcherAssert.assertThat(repo.labels().iterate().iterator().hasNext(), Matchers.equalTo(true));
}
use of com.jcabi.github.RtGithub in project wring by yegor256.
the class AgGithub method push.
@Override
public String push(final Events events) throws IOException {
final Github github = new RtGithub(this.config.getString("token"));
final String since = DateFormatUtils.formatUTC(DateUtils.addMinutes(new Date(), -Tv.THREE), "yyyy-MM-dd'T'HH:mm:ss'Z'");
final Request req = github.entry().uri().path("/notifications").back();
final Iterable<JsonObject> list = new RtPagination<>(req.uri().queryParam("participating", "true").queryParam("since", since).queryParam("all", Boolean.toString(true)).back(), RtPagination.COPYING);
final Collection<String> done = new LinkedList<>();
for (final JsonObject event : AgGithub.safe(list)) {
final String reason = event.getString("reason");
if (!"mention".equals(reason)) {
continue;
}
this.push(github, event, events);
done.add(event.getString("id"));
}
req.uri().queryParam("last_read_at", since).back().method(Request.PUT).body().set("{}").back().fetch().as(RestResponse.class).assertStatus(HttpURLConnection.HTTP_RESET);
if (!done.isEmpty()) {
Logger.info(this, "%d GitHub events for @%s processed: %s", done.size(), github.users().self().login(), done);
}
return String.format("%d events for @%s at %s", done.size(), github.users().self().login(), DateFormatUtils.formatUTC(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
Aggregations