Using VersionEye through the CloudRail API

CloudRail makes it easier for you to integrate services via an API into your application. So let’s say you need to integrate VersionEye to monitor projects, Twilio for SMS and Sendgrid for Mails. These are 3 totally different API you need to learn and work with. It’s pretty obvious that this takes a lot of time. This doesn’t even include the time it takes to maintain those integrations or to work with these across platforms.

CloudRail provides you with a universal API. This means you can access all services via a single API. So just one API to learn and a single SDK to integrate and maintain. CloudRail bundles all APIs you need into a SDK which is specifically generated for your needs by the system. All communication then happens via the SDK and the services you integrate. This means we never touch the data and CloudRail even works in an offline environment (as long as it’s an internal network based API, e.g. Philips Hue). The cool thing is, CloudRail is completely free, even for commercial projects.

How to use it?

The first step of using CloudRail is to configure your requirements. This happens via a simple online tool. Here you just select all services you need to integrate.

For the example app for VersionEye, we will be sending out a text message via Twilio if a package has been updated on VersionEye. Using the same methods here, you could also expand the scope of your applications to send emails to your team via MailChimp, or even create a new blank project folder in your company’s dropbox account. Once you have completed this tutorial, you will be able to add all of these completely different APIs in exactly the same way, without having to read the documentation for each.

—Step 1: Select your integrations—

First, go to the CloudRail Workbench and, if you haven’t already yet, create an account.

Once you have logged in, or signed up, you will be able to click on a button to create a custom API. To follow this tutorial exactly, for the name, use “TextOnUpdate”

In the next screen just select the check boxes for both VersionEye and Twilio

Screen Shot 2016-03-04 at 11.23.34

In the following screen, you can edit the functions. This allows you to change inputs and outputs as needed. But, for this example, we just need all the default functions, so simply click on the “Continue & Export SDK button”.

From this screen, you then be able to download the SDK for your development environment of choice. We will be downloading the Java SDK for this example, but do note all of the other SDKs we have, including Android.

Screen Shot 2016-02-24 at 15.48.54

—Step 2: Adding the Code—

In this example, we will be using Eclipse, so load it up and create a new project. If you are using a different development environment, you will have to adapt these instructions for your particular workflow

Extract the zip file that you have downloaded and open the contained “java” folder

Add the JAR file to the build path of your project (add it to the main folder, right click, and select “Build > Add to Build Path”) and the com folder into your project source

Create a new class, named SendTextOnUpdate, and add the following code:


//Create all needed imports

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;

import com.cloudrail.exception.CloudRailException;
import com.cloudrail.userInterface.TextOnUpdate;

//These two are the event listeners for the functions in our API
import com.cloudrail.userInterface.TextOnUpdate.GetPackageInfoResponseListener;
import com.cloudrail.userInterface.TextOnUpdate.SendSMSResponseListener;

public class SendTextOnUpdate {

  public static void main(String[] args) throws UnsupportedEncodingException {

  //Replace with your own VersionEyeAPIKey
  final String versioneyeapikey = "ABCDE123"; 

  //The following block are the items we need to use the Twilio Integration
  final String sender = "+15005550006";
  final String recipient = "+78798"; 

  /*
  * The next line needs to be within Base64 format.
  * To do this, go to https://www.base64encode.org/, and insert in
  * Your API key and your account ID, seperated out with a colon, like this
  * TwilioApiKey:AccountsId And paste the results into the varable below.
  */
  final String apikey = "ABCDE123"; // Change to your API key
  final String accountsid = "ABCDE123"; //Change to your own Twilio account ID
  //-------------------------

  // These are the variables we will be using for a project ID and a
  // previous version number. Of course, in a real program
  // These would be obtained in some other way.
  final String packagekey = "firebase/angularfire";
  final String programminglang = "javascript";
  final String packageversion = "1.1.4";
  final String textlastsent = "2016-02-23T03:07:37.227Z";

  // We pass our global variable to the constructor here
  TextOnUpdate textupdatesclass = new TextOnUpdate(versioneyeapikey); 

  textupdatesclass.getPackageInfo(packageversion, programminglang, packagekey, new GetPackageInfoResponseListener(){

    @Override
    public void onSuccess(String description, List<Object> dependencies_list, List<Object> licenses_list, String updatedat, String licenseinfo, String prodkey) {
      if (!updatedat.equals(textlastsent)) {
        textupdatesclass.sendSMS(sender, recipient, "Package has Updated", apikey, accountsid, new SendSMSResponseListener(){

        @Override
        public void onSuccess() {
          System.out.println("Text was Sent!");
        }

        @Override
        public void onError(CloudRailException error) {
          System.out.println(error);
        }

        @Override
        public void onProgress(double percentFinished) {
          // TODO Auto-generated method stub
        }
      });
      } else {
        System.out.println("No Update!");
      }
    }

    @Override
    public void onError(CloudRailException error) {
      error.printStackTrace();
    }

    @Override
    public void onProgress(double percentFinished) {
      // TODO Auto-generated method stub
    }

   });

  }
}

The source is available in this Gist as well: https://gist.github.com/reiz/903aedbcf1270bb25179

—Step3: Run and Enjoy—

And that’s it. You can now run the program and it will send a message to your number if the package has updated.

Of course, you can then expand this code to take inputs, or to check the items on a schedule. You can also use the combined power of VersionEye, and any other integration, to help automate your business processes when a new library update happens.

As CloudRail is still being constantly updated (we’ve just recently updated the Workbench to make it easier to use, for example), it is also a good idea to check out the CloudRail Documentation at https://cloudrail.com/documentation/) to see if we have updated any aspect of the implementation of the CloudRail SDK. Also, currently CloudRail is available for Java and Android, and we are working hard to also bring the CloudRail Universal SDK for iOS and Node.js developers. You can check out the progress of this as well see a list of all of the current definitions in CloudRail, at the CloudRail Features page.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s