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

Commit 1e02366

Browse files
committed
Save num_notifs in DevRant
1 parent 1d003c8 commit 1e02366

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class DevRant {
5555
private Auth auth;
5656
private int timeout = 15000;
5757
private boolean hideReposts = false;
58+
private int numNotifs;
5859

5960
/**
6061
* Log in to devRant.
@@ -403,12 +404,19 @@ private JsonObject executeRequest(Request request) {
403404
}
404405

405406
// Parse the response as json.
407+
JsonObject json;
406408
try (JsonReader reader = new JsonReader(new InputStreamReader(stream))) {
407-
return new JsonParser().parse(reader).getAsJsonObject();
409+
json = new JsonParser().parse(reader).getAsJsonObject();
408410
} catch (IOException e) {
409411
LOGGER.error("Exception while trying to create JsonReader.", e);
410412
return null;
411413
}
414+
415+
// Save the amount of notifs.
416+
if (json.has("num_notifs"))
417+
numNotifs = json.get("num_notifs").getAsInt();
418+
419+
return json;
412420
}
413421

414422
/**
@@ -442,4 +450,11 @@ public void setHideReposts(boolean hideReposts) {
442450
public boolean getHideReposts() {
443451
return hideReposts;
444452
}
453+
454+
/**
455+
* Get the amount of notifications the user has.
456+
*/
457+
public int getNotifCount() {
458+
return numNotifs;
459+
}
445460
}

0 commit comments

Comments
 (0)