/versioneye-api

Elegant OOP wrapper over the VersionEye API

Primary LanguageJavaBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

versioneye-api

Build Status Coverage Status DevOps By Rultor.com PDD status

Elegant OOP wrapper over the VersionEye API

Design

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.

Usage

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:

  1. 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")
    );
  1. 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")
    );
  1. 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

Contribute

Contributors are welcome

  1. Open an issue regarding an improvement you thought of, or a bug you noticed, or ask to be assigned to an existing one.
  2. If the issue is confirmed, fork the repository, do the changes on a separate branch and make a Pull Request.
  3. After review and acceptance, the PR is merged and closed.
  4. 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.