11# JavaRant
2- A devRant wrapper for Java.
2+ A devRant API wrapper for Java.
33
44## Using JavaRant
5- JavaRant is available on Maven, simply add this dependency to your pom.xml file:
5+ JavaRant is available on Maven, simply add this dependency to your ` pom.xml ` file:
66
7- <dependency>
8- <groupId>com.scorpiac.javarant</groupId>
9- <artifactId>javarant</artifactId>
10- <version>1.0</version>
11- </dependency>
7+ ```
8+ <dependency>
9+ <groupId>com.scorpiac.javarant</groupId>
10+ <artifactId>javarant</artifactId>
11+ <version>1.0</version>
12+ </dependency>
13+ ```
1214
1315## Class overview
1416
@@ -18,12 +20,19 @@ From here you can get a list of rants, get a random rant, or search for rants co
1820
1921Examples:
2022
21- // Get the first 10 rants.
22- Rant[] rants = DevRant.getRants(Sort.ALGO, 10, 0);
23- // Get a random rant.
24- Rant random = DevRant.surprise();
25- // Search for rants containing "wtf".
26- Rant[] wtf = DevRant.search("wtf");
23+ ```
24+ // Get the first 10 rants.
25+ Rant[] rants = DevRant.getRants(Sort.ALGO, 10, 0);
26+
27+ // Get a random rant.
28+ Rant random = DevRant.surprise();
29+
30+ // Search for rants containing "wtf".
31+ Rant[] wtf = DevRant.search("wtf");
32+
33+ // Get the weekly rants.
34+ Rant[] weekly = DevRant.weekly();
35+ ```
2736
2837### RantContent
2938This is the base class for rants and comments, which have the following attributes:
@@ -33,51 +42,62 @@ This is the base class for rants and comments, which have the following attribut
3342- upvotes
3443- downvotes
3544- content
45+ - image
3646
37- Additionally you can call getScore() which calculates the total score.
47+ Additionally you can call ` getScore() ` which calculates the total score.
3848
3949### Rant
40- Rants are get through one of the methods in DevRant, or by an id using byId(id).
41- This will throw a NoSuchRantException if the id is invalid.
42- In addition to the RantContent attributes, a rant also contains:
50+ Rants are get through one of the methods in ` DevRant ` , or by an id ( ` Rant. byId(id) ` ).
51+ This will throw a ` NoSuchRantException ` if the id is invalid.
52+ In addition to the ` RantContent ` attributes, a ` Rant ` also contains:
4353
44- - image
4554- tags
4655- commentCount
4756- comments
4857
49- The comments can be accessed by calling getComments().
58+ The comments can be accessed by calling ` getComments() ` .
5059This will also fetch them if that has not been done yet.
51- Alternatively you can call fetchComments() to force fetching the comments.
60+ Alternatively you can call ` fetchComments() ` to fetch the comments, or ` fetchComments(force) ` to force fetch them (i.e. fetch them again) .
5261
5362Examples:
5463
55- // Get a rant by its id.
56- Rant rant = Rant.byId(136761);
57- // Fetch and get the comments.
58- Comment[] comments = rant.getComments();
59- // Force fetch the comments.
60- boolean success = rant.fetchComments();
64+ ```
65+ // Get a rant by its id.
66+ Rant rant = Rant.byId(136761);
67+
68+ // Fetch and get the comments.
69+ Comment[] comments = rant.getComments();
70+
71+ // Force fetch the comments.
72+ boolean success = rant.fetchComments(true);
73+ ```
6174
6275### Comment
63- A comment only contains the attributes from RantContent.
76+ A comment only contains the attributes from ` RantContent ` .
77+
78+ ### Image
79+ An image contains a link to the image on devRant, and a width and height.
6480
6581### User
66- Users can be get from rants, comments, or by id or username.
67- The latter two will throw a NoSuchUserException for non-existing users.
82+ Users can be get from rants, comments, by id ( ` User.byId(id) ` ) or username ( ` User.byUsername(username) ` ) .
83+ The latter two will throw a ` NoSuchUserException ` for non-existing users.
6884When they are get from a rant or comment, only the id, username and score are given.
6985The other data will be fetched and stored as soon as it's accessed.
70- Alternatively you can force fetch the data by calling fetchData().
86+ Alternatively you can fetch the data by calling ` fetchData() ` , or ` fetchData(force) ` to force fetch the data (i.e. fetch it again ).
7187
7288Examples:
7389
74- // Get a user by their id.
75- User me = User.byId(102959);
76- // Get a user by their username
77- User alsoMe = User.byUsername("LucaScorpion");
78- // If the user data is not fetched, do so.
79- if (!me.isFetched())
80- boolean success = me.fetchData();
90+ ```
91+ // Get a user by their id.
92+ User me = User.byId(102959);
93+
94+ // Get a user by their username.
95+ User alsoMe = User.byUsername("LucaScorpion");
96+
97+ // Fetch the data.
98+ boolean success = me.fetchData();
99+ ```
81100
82101### Sort
83- This is an enum containing the sort options which are used by DevRant.getRants. You can pick between ALGO, RECENT or TOP.
102+ These are the different sort options which are used by ` DevRant.getRants ` .
103+ You can pick between ` ALGO ` , ` RECENT ` or ` TOP ` .
0 commit comments