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

LucaScorpion/JavaRant

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

JavaRant

A devRant API wrapper for Java.

Maven Central Jenkins Jenkins tests

Maven

JavaRant is available on Maven, simply add this dependency to your pom.xml file:

<dependency>
	<groupId>com.scorpiac.javarant</groupId>
	<artifactId>javarant</artifactId>
	<version>2.1.0</version>
</dependency>

Using JavaRant

To access devRant simply create a new DevRant object:

DevRant devRant = new DevRant();

The DevRant class itself can be used to get specific rants and users.

// Get a specific rant.
CommentedRant rant = devRant.getRant(686001);

// Get a user by username.
User me = devRant.getUser("LucaScorpion");

The DevRant class contains 2 methods for getting to specific parts of the api. First, getFeed() which returns a DevRantFeed object. This is used to access the rant and collab feeds.

// Get the 10 latest rants.
List<Rant> recent = devRant.getFeed().getRants(Sort.RECENT, 10, 0);

// Get the 10 best stories.
List<Rant> stories = devRant.getFeed().getStories(Sort.TOP, 0);

// Get 10 collabs.
List<Collab> collabs = devRant.getFeed().getCollabs(10);

Second, getAuth() which returns a DevRantAuth object, which is used to access user functionality. Note that a user needs to be logged in before this can be accessed.

// Log in to devRant.
char[] password = "<password>".toCharArray();
devRant.login("<username>", password);

// Upvote a rant.
devRant.getAuth().voteRant(832125, Vote.UP);

// Clear the vote on a comment.
devRant.getAuth().voteComment(832169, Vote.NONE);

// Log out to clear the token.
devRant.logout();