Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit 26d68fb

Browse files
committed
Add comment posting
1 parent aa614e5 commit 26d68fb

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/main/java/com/scorpiac/javarant/DevRant.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,30 @@ public boolean postRant(String rant, String tags) {
303303
));
304304
}
305305

306+
/**
307+
* Post a comment.
308+
*
309+
* @param rant The rant to post the comment on.
310+
* @param comment The content of the comment.
311+
* @return Whether posting the comment was successful.
312+
*/
313+
public boolean postComment(Rant rant, String comment) {
314+
return postComment(rant.getId(), comment);
315+
}
316+
317+
/**
318+
* Post a comment.
319+
*
320+
* @param rantId The id of the rant to post the comment on.
321+
* @param comment The content of the comment.
322+
* @return Whether posting the comment was successful.
323+
*/
324+
public boolean postComment(int rantId, String comment) {
325+
// Rants url, rant, comments url.
326+
String url = String.format("%1$s/%2$d%3$s", API_RANTS, rantId, API_COMMENT);
327+
return Util.jsonSuccess(post(url, new BasicNameValuePair("comment", comment)));
328+
}
329+
306330
/**
307331
* Make a POST-request to the devRant server.
308332
*

0 commit comments

Comments
 (0)