Elegant OOP wrapper over the VersionEye API
Apparently VersionEye will shut down by the end of 2017: https://blog.versioneye.com/2017/10/19/versioneye-sunset-process/ There is no point in continuing development here. This repository remains, however, as guidance/documentation for future Java REST clients.
This library is 100% object oriented, based on interfaces and final classes. It has one single entry point, RtVersionEye, which is the only public class. Everything is encapsulated, wrapped in intuitive interfaces. The main goal is to offer a well organized, user-friendly library that's easy to use.
Behind the scenes the jcabi-http client is used, mainly for the convenient and fluent API that it offers. Json is manipulated using javax.json API with the Glassfish implementation.
For unit-testing, a mock version is offered, which holds a JsonBuilder behind, instead of making real HTTP requests.
There is one single entry point and the usage is fluent. Everyone should be able to start using this library in a matter of minutes:
- Pinging:
VersionEye api = new RtVersionEye();
JsonObject json = api.services().ping();
MatcherAssert.assertThat(
json.getBoolean("success"), Matchers.is(true)
);
MatcherAssert.assertThat(
json.getString("message"), Matchers.is("pong")
);
- Getting information about me (the authenticated used):
Authenticated user = new RtVersionEye("...token...").me().about();
MatcherAssert.assertThat(
user.fullName(), Matchers.is("Mihai Emil Andronache")
);
MatcherAssert.assertThat(
user.username(), Matchers.is("amihaiemil")
);
- Getting a user's comments (same for Favorites):
VersionEye versionEye = new RtVersionEye("...token...");
Comments comments = versionEye.users().user("amihaiemil").comments();
List<Comment> firstPage = comments.fetch(1);//first page of comments
for(Page<Comment> page : comments.paginated()) {
//iterate over all the comments pages (including the first one)
List<Comment> onPage = page.fetch();
}
@todo #9:15min/DEV Add more examples of usage here
Contributors are welcome
- Open an issue regarding an improvement you thought of, or a bug you noticed, or ask to be assigned to an existing one.
- If the issue is confirmed, fork the repository, do the changes on a separate branch and make a Pull Request.
- After review and acceptance, the PR is merged and closed.
- You are automatically listed as a contributor on the repo and the project's site (to follow)
Make sure the maven build
$ mvn clean install -Pcheckstyle
passes before making a PR.