This repository was archived by the owner on Jan 5, 2019. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/java/com/scorpiac/javarant Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments