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

Commit 0b7cf13

Browse files
committed
Add option to hide reposts
1 parent 8a3658b commit 0b7cf13

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

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

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public class DevRant {
4848

4949
private Auth auth;
5050
private int timeout = 15000;
51+
private boolean hideReposts = false;
5152

5253
/**
5354
* Log in to devRant.
@@ -130,7 +131,7 @@ public List<Rant> search(String term) {
130131
}
131132

132133
/**
133-
* Get a random rant with at least 15 +1's.
134+
* Get a random rant with at least 15 ++'s.
134135
*
135136
* @return A random rant.
136137
*/
@@ -174,6 +175,25 @@ public List<Collab> getCollabs() {
174175
return Util.jsonToList(json.get("rants").getAsJsonArray(), elem -> Collab.fromJson(this, elem.getAsJsonObject()));
175176
}
176177

178+
/**
179+
* Get the story rants.
180+
*
181+
* @return The story rants.
182+
*/
183+
public List<Rant> getStories(Sort sort, int limit, int skip) {
184+
JsonObject json = get(API_STORIES,
185+
new BasicNameValuePair("sort", sort.toString()),
186+
new BasicNameValuePair("limit", String.valueOf(limit)),
187+
new BasicNameValuePair("skip", String.valueOf(skip))
188+
);
189+
190+
// Check for success.
191+
if (!Util.jsonSuccess(json))
192+
return null;
193+
194+
return Util.jsonToList(json.get("rants").getAsJsonArray(), elem -> Rant.fromJson(this, elem.getAsJsonObject()));
195+
}
196+
177197
/**
178198
* Get a rant by its id.
179199
*
@@ -365,6 +385,7 @@ private List<NameValuePair> getParameters(NameValuePair... params) {
365385
// Add the parameters which always need to be present.
366386
paramList.add(new BasicNameValuePair("app", APP_ID));
367387
paramList.add(new BasicNameValuePair("plat", PLAT_ID));
388+
paramList.add(new BasicNameValuePair("hide_reposts", hideReposts ? "1" : "0"));
368389

369390
// Add the auth information.
370391
if (isLoggedIn()) {
@@ -416,4 +437,20 @@ public void setRequestTimeout(int timeout) {
416437
public int getRequestTimeout() {
417438
return timeout;
418439
}
440+
441+
/**
442+
* Set whether to hide reposts.
443+
*
444+
* @param hideReposts Whether to hide reposts.
445+
*/
446+
public void setHideReposts(boolean hideReposts) {
447+
this.hideReposts = hideReposts;
448+
}
449+
450+
/**
451+
* Get whether to hide reposts.
452+
*/
453+
public boolean getHideReposts() {
454+
return hideReposts;
455+
}
419456
}

0 commit comments

Comments
 (0)