You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 5, 2019. It is now read-only.
It can also be used to get specific items based on an id (or username).
38
+
These methods will throw an exception if the specified item does not exist (`NoSuchRantException` for rants and `NoSuchUserException` for users).
39
+
Additionally, `getCollab` will also throw a `NotACollabException` if the requested rant is a normal rant instead of a collab.
40
+
41
+
```
42
+
Rant rant = devRant.getRant(422850);
43
+
Collab collab = devRant.getCollab(420025);
44
+
45
+
User me = devRant.getUser("LucaScorpion");
46
+
User me2 = devRant.getUser(102959);
47
+
```
48
+
49
+
To post or vote anything we first need to log in.
50
+
This will make a request to get an authentication token, which is stored for later use.
51
+
Your username and password will _not_ be stored.
52
+
The login method uses `char[]` instead of `String` for the password parameter for security reasons (and most of the times you have a password it should already be in the form of a `char[]`).
devRant.postRant("Hello world!", "hello, not a rant");
26
73
27
-
// Get a random rant.
28
-
Rant random = DevRant.surprise();
74
+
devRant.postComment(rant, "This is a comment.");
75
+
devRant.postComment(424553, "And another one.");
76
+
```
29
77
30
-
// Search for rants containing "wtf".
31
-
Rant[] wtf = DevRant.search("wtf");
78
+
You can log out to clear the authorization token.
32
79
33
-
// Get the weekly rants.
34
-
Rant[] weekly = DevRant.weekly();
80
+
```
81
+
devRant.logout();
35
82
```
36
83
37
84
### RantContent
@@ -41,15 +88,12 @@ This is the base class for rants and comments, which have the following attribut
41
88
- user
42
89
- upvotes
43
90
- downvotes
91
+
- score
44
92
- content
45
93
- image
46
94
47
-
Additionally you can call `getScore()` which calculates the total score.
48
-
49
95
### Rant
50
-
Rants are get through one of the methods in `DevRant`, or by an id (`Rant.byId(id)`).
51
-
The latter will throw a `NoSuchRantException` if the id is invalid.
52
-
In addition to the `RantContent` attributes, a `Rant` also contains:
96
+
In addition to the `RantContent` attributes, rants also contain:
53
97
54
98
- tags
55
99
- commentCount
@@ -59,24 +103,9 @@ The comments can be accessed by calling `getComments()`.
59
103
This will also fetch them if that has not been done yet.
60
104
Alternatively you can call `fetchComments()` to fetch the comments, or `fetchComments(force)` to force fetch them (i.e. fetch them again).
61
105
62
-
Examples:
63
-
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
-
```
74
-
75
106
### Collab
76
107
Collabs are an extension of rants.
77
-
They are get through `DevRant.collabs()` or by an id (`Collab.byId(id)`).
78
-
The latter will throw a `NoSuchRantException` if the id is invalid, or a `NotACollabException` if it is simply a rant instead of a collab.
79
-
Besides the attributes from a rant, collabs have the following attributes:
108
+
Besides the attributes from a rant, collabs contain the following:
80
109
81
110
- projectType
82
111
- description
@@ -87,42 +116,26 @@ Besides the attributes from a rant, collabs have the following attributes:
87
116
Like with a rant the comments can be fetched or force fetched.
88
117
There is also more data which needs to be fetched, similar to the comments this is done by calling `fetchData()` or `fetchData(force)` to force fetch it.
89
118
90
-
Examples:
91
-
92
-
```
93
-
// Get a collab by its id.
94
-
Collab collab = Collab.byId(420392);
95
-
96
-
// Force fetch the data.
97
-
boolean success = collab.fetchData(true);
98
-
```
99
-
100
119
### Comment
101
120
A comment only contains the attributes from `RantContent`.
102
121
103
122
### Image
104
-
An image contains a link to the image on devRant, and a width and height.
123
+
An image has the following attributes:
124
+
125
+
- url
126
+
- width
127
+
- height
105
128
106
129
### User
107
-
Users can be get from rants, comments, by id (`User.byId(id)`) or username (`User.byUsername(username)`).
108
-
The latter two will throw a `NoSuchUserException` for non-existing users.
130
+
Users can be get from rants, comments, by id or username.
109
131
When they are get from a rant or comment, only the id, username and score are given.
110
132
The other data will be fetched and stored as soon as it's accessed.
111
133
Alternatively you can fetch the data by calling `fetchData()`, or `fetchData(force)` to force fetch the data (i.e. fetch it again).
112
134
113
-
Examples:
114
-
115
-
```
116
-
// Get a user by their id.
117
-
User me = User.byId(102959);
118
-
119
-
// Get a user by their username.
120
-
User alsoMe = User.byUsername("LucaScorpion");
121
-
122
-
// Fetch the data.
123
-
boolean success = me.fetchData();
124
-
```
125
-
126
135
### Sort
127
-
These are the different sort options which are used by `DevRant.getRants`.
136
+
These are the different sort options, which are used when getting rants from the feed.
128
137
You can pick between `ALGO`, `RECENT` or `TOP`.
138
+
139
+
### Vote
140
+
These are the different vote options, which are used to vote on rants and comments.
0 commit comments