Javascript SDK

The eviti Web API SDK for JavaScript provides a rich set of client-side functionality for making API calls and implementing eviti Login/Logout.

Download eviti SDK 1.0

Web API Documentation



Features

  • Login / Logout functionality
  • Effortlessly make API calls
  • sessionStorage / cookie token handling
  • Developer console debugging (if enabled)

Requirements

jQuery version (1.6+)

CORS compatibile browser


CORS Browser Requirements

  • Blackberry Browser 7+
  • Internet Explorer 10+ (8/9 partial support)
  • Firefox 3.5+
  • Chrome 4+
  • Safari 4+
  • Opera 12+
  • IOS Safari (all / 3.2+)
  • Android Browser (all / 2.1+)
  • Opera Mobile 12+
View Example SDK Implementation

Methods

EV.init()

Used to set the Web API to a specific version, or enable internal console logging (off by default), allowing the developer to see when calls are fired / error out / etc.
Optional (if not called or left blank : loads newest version of Web API)
EV.init();
// Optional Object parameters
EV.init({
    version: '',            // OPTIONAL - (defaults to '' nothing or LATEST version)
    errorLogging : false    // OPTIONAL - (defaults to false)
});


EV.login()

Used to login a user based on a username / password.
Returns a Bearer token that is saved within sessionStorage and used by all further EV.api() calls.
EV.login({
    username: '',
    password: '',
    callback: function (response) { },                      // OPTIONAL - Handle successful Login
    error: function (jqXHR, textStatus, errorThrown) { },   // OPTIONAL - Handle invalid Login
});


EV.api()

EV.api() allows easy access to eviti's RESTful Web API, and handles the token headers for you.
You can also access the RESTful resources by supplying the path, for example 'cancerTypes' as opposed to the entire URL.

For example:
path : 'cancerType'
Not
path : 'https://connect.eviti.com/api/cancertypes'
EV.api({
    path : '',                                              // Pathname to Controller - IE: 'cancerTypes' / 'Toxicities'
    method : '',                                            // OPTIONAL - (type of Request [GET by default])
    params : {},                                            // Data being passed in {object} or 'STRING'
    callback : function (response) { },                     // OPTIONAL - Handle success
    error : function (jqXHR, textStatus, errorThrown) { }   // OPTIONAL - Handle error
});
// Example useage:
EV.api({
    path : 'cancertypes',
    callback: function (response) { },                      // OPTIONAL - Handle success response
    error: function (jqXHR, textStatus, errorThrown) { },   // OPTIONAL - Handle error
});


EV.logout()

Kills sessionStorage token.
EV.logout();
Example Implementation
// Include the evitiAPI file
<script src="evitiAPI.js"></script>
// Gather username/password then:
///////////////////////////////////////
EV.login({
    username: 'xxxx',
    password: 'xxxx',
    callback: function (response) {
        alert('Logged in Successfully!');
    },
    error: function (xhr, status, error) {
        alert('Invalid credentials!');
    }
});
// EXAMPLE API ACCESS
// Example [GET] (Default for .api())
///////////////////////////////////////
EV.api({
    path: 'cancertypes',
    callback: function (response) {
        // Do something with the JSON
    }
});
// Example simple [GET]
// Get specific Cancer for Breast (Guid BD5CC60C-EEAD-DE11-9A32-0021973E4A38)
///////////////////////////////////////
EV.api({
    path: 'cancertypes',
    params: 'BD5CC60C-EEAD-DE11-9A32-0021973E4A38',
    callback: function (response) {
        // Do something
    }
});
// Example Data object [GET]
///////////////////////////////////////
EV.api({
    path: 'example',
    params: {
        something: '123',
        another: 'XXXX-XXXX-GUID'
    },
    callback:function (response) {
        // Do something
    }
});
// Example Data object [POST]
///////////////////////////////////////
EV.api({
    method: 'POST',
    path: 'example',
    params: {
        something: '123',
        another: 'XXXX-XXXX-GUID'
    },
    callback:function (response) {
        // Do something
    }
});
// Logout
///////////////////////////////////////
EV.logout();