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

Commit 26f6331

Browse files
committed
Add weekly rants
1 parent ef3bd91 commit 26f6331

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class DevRant {
2424
static final String API_SURPRISE_URL = API_RANTS_URL + "/surprise";
2525
static final String API_USERS_URL = API_URL + "/users";
2626
static final String API_USER_ID_URL = API_URL + "/get-user-id";
27+
static final String API_WEEKLY_URL = API_URL + "/devrant/weekly-rants";
2728

2829
/**
2930
* Get a list of rants.
@@ -80,6 +81,23 @@ public static Rant surprise() {
8081
return Rant.fromJson(json.get("rant").getAsJsonObject());
8182
}
8283

84+
/**
85+
* Get the weekly rants.
86+
*
87+
* @return The weekly rants.
88+
*/
89+
public static Rant[] weekly() {
90+
// Weekly url, app id.
91+
String url = String.format("%1$s?app=%2$s", API_WEEKLY_URL, APP_ID);
92+
JsonObject json = request(url);
93+
94+
// Check for success.
95+
if (!Util.jsonSuccess(json))
96+
return null;
97+
98+
return Util.jsonToList(json.get("rants").getAsJsonArray(), elem -> Rant.fromJson(elem.getAsJsonObject())).toArray(new Rant[0]);
99+
}
100+
83101
/**
84102
* Make a request to the DevRant server.
85103
*
@@ -125,6 +143,7 @@ static String link(String url) {
125143

126144
/**
127145
* Create a link to an avatar.
146+
*
128147
* @param avatarUrl The avatar url.
129148
* @return The complete url.
130149
*/

0 commit comments

Comments
 (0)