@Override public RequestBody body() { return this.base.body(); }
@Override public RequestBody body() { return this.base.body(); }
@Override public RequestBody body() { return this.request.body(); } @Override
@Override public RequestBody body() { return this.base.body(); }
@Override public void react(final Reaction reaction) throws IOException { final JsonStructure json = Json.createObjectBuilder() .add(RtIssue.CONTENT, reaction.type()) .build(); this.request.method(Request.POST) .body().set(json).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK); }
@Override public void react(final Reaction reaction) throws IOException { final JsonStructure json = Json.createObjectBuilder() .add(RtComment.CONTENT, reaction.type()) .build(); this.request.method(Request.POST) .body().set(json).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK); }
@Override public void lock(final String reason) { final JsonStructure json = Json.createObjectBuilder() .add("lock_reason", reason) .build(); try { this.request.method(Request.PUT).uri().path("/lock").back() .body().set(json).back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_NO_CONTENT); } catch (final IOException error) { throw new IllegalStateException(error); } }
@Override public Reference create( final String ref, final String sha ) throws IOException { final JsonObject json = Json.createObjectBuilder() .add("sha", sha).add(RtReferences.REF, ref).build(); return this.get( this.request.method(Request.POST) .body().set(json).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_CREATED) .as(JsonResponse.class) .json().readObject().getString(RtReferences.REF) ); }
@Override public boolean isLocked() { boolean locked = false; try { locked ^= this.request.method(Request.PUT).uri().path("/lock").back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_NO_CONTENT).back().body() .get().isEmpty(); } catch (final IOException error) { locked = false; } return locked; }
@Override public Fork create( final String organization) throws IOException { final JsonStructure json = Json.createObjectBuilder() .add("organization", organization) .build(); return this.get( this.request.method(Request.POST) .body().set(json).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_ACCEPTED) .as(JsonResponse.class) .json().readObject().getInt(ID) ); }
/** * Helper method for merge operations. * @param payload The JSON payload for the merge * @return Response received from GitHub * @throws IOException If there is any I/O problem */ private RestResponse merge(final JsonStructure payload) throws IOException { return this.request.uri() .path("/merge").back() .body().set(payload).back() .method(Request.PUT) .fetch() .as(RestResponse.class); }
@Override public void remove(final Iterable<String> emails) throws IOException { final JsonArrayBuilder json = Json.createArrayBuilder(); for (final String email : emails) { json.add(email); } this.request.method(Request.DELETE) .body().set(json.build()).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_NO_CONTENT); }
@Override public void post(final String text) throws IOException { this.request.fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel("/page/links/link[@rel='post']/@href") .method(Request.POST) .body().formParam("text", text).back() .fetch(); Logger.info(this, "message posted"); }
@Override public Commit create( final JsonObject params ) throws IOException { return this.get( this.request.method(Request.POST) .body().set(params).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_CREATED) .as(JsonResponse.class) .json().readObject().getString("sha") ); }
@Override public Tree create( final JsonObject params ) throws IOException { return this.get( this.request.method(Request.POST) .body().set(params).back() .fetch().as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_CREATED) .as(JsonResponse.class) .json().readObject().getString("sha") ); } }
@Override public void create(final String name) throws IOException { this.request.fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel("/page/links/link[@rel='create']/@href") .method(Request.POST) .body().formParam("name", name).back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_SEE_OTHER); Logger.info(this, "attachment '%s' created", name); }
@Override public void rename(final String text) throws IOException { this.request.fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel("/page/links/link[@rel='rename']/@href") .method(Request.POST) .body().formParam("title", text).back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_SEE_OTHER); Logger.info(this, "bout #%d renamed", this.num); }
@Override public void add(final Iterable<String> labels) throws IOException { JsonArrayBuilder builder = Json.createArrayBuilder(); for (final String label : labels) { builder = builder.add(label); } final JsonStructure json = builder.build(); this.request.method(Request.POST) .body().set(json).back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(JsonResponse.class) .json().readArray(); }
@Override public void replace(final Iterable<String> labels) throws IOException { JsonArrayBuilder builder = Json.createArrayBuilder(); for (final String label : labels) { builder = builder.add(label); } final JsonStructure json = builder.build(); this.request.method(Request.PUT) .body().set(json).back() .fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(JsonResponse.class) .json().readArray(); }
@Override public void email(final String email) throws IOException { this.request.fetch() .as(RestResponse.class) .assertStatus(HttpURLConnection.HTTP_OK) .as(XmlResponse.class) .rel("/page/links/link[@rel='account']/@href") .fetch() .as(XmlResponse.class) .rel("/page/links/link[@rel='save-email']/@href") .method(Request.POST) .body().formParam("email", email).back() .fetch(); Logger.info(this, "email changed"); }