lib/RestClient.js
function RestClient(apikey, options) {

    //Required client config
    if (!apikey) {
        if (process.env.GAVAGAI_APIKEY) {
            this.apikey = process.env.GAVAGAI_APIKEY;
        }
        else {
            throw new Error('RestClient requires an apikey set explicitly or via the GAVAGAI_APIKEY environment variable');
        }
    }
    else {
        this.apikey = apikey.trim();
    }

    //Optional client config
    options = options || {};
    this.host = options.host || defaultHost;
    this.apiVersion = options.apiVersion || defaultApiVersion;
    this.timeout = options.timeout || defaultTimeOut;

    // Resources
    this.stories = require('./stories')(this);
    this.tonality = require('./tonality')(this);
    this.topics = require('./topics')(this);
    this.keywords = require('./keywords')(this);
    this.lexicon = require('./lexicon')(this);
}
function RestClient(apikey, options) {

    //Required client config
    if (!apikey) {
        if (process.env.GAVAGAI_APIKEY) {
            this.apikey = process.env.GAVAGAI_APIKEY;
        }
        else {
            throw new Error('RestClient requires an apikey set explicitly or via the GAVAGAI_APIKEY environment variable');
        }
    }
    else {
        this.apikey = apikey.trim();
    }

    //Optional client config
    options = options || {};
    this.host = options.host || defaultHost;
    this.apiVersion = options.apiVersion || defaultApiVersion;
    this.timeout = options.timeout || defaultTimeOut;

    // Resources
    this.stories = require('./stories')(this);
    this.tonality = require('./tonality')(this);
    this.topics = require('./topics')(this);
    this.keywords = require('./keywords')(this);
    this.lexicon = require('./lexicon')(this);
}
function RestClient ( apikey , options ) { //Required client config if ( ! apikey ) { if ( process . env . GAVAGAI_APIKEY ) { this . apikey = process . env . GAVAGAI_APIKEY ; } else { throw new Error ( 'RestClient requires an apikey set explicitly or via the GAVAGAI_APIKEY environment variable' ) ; } } else { this . apikey = apikey . trim ( ) ; } //Optional client config options = options || { } ; this . host = options . host || defaultHost ; this . apiVersion = options . apiVersion || defaultApiVersion ; this . timeout = options . timeout || defaultTimeOut ; // Resources this . stories = require ( './stories' ) ( this ) ; this . tonality = require ( './tonality' ) ( this ) ; this . topics = require ( './topics' ) ( this ) ; this . keywords = require ( './keywords' ) ( this ) ; this . lexicon = require ( './lexicon' ) ( this ) ; }
The Gavagai REST API client
@constructor
@param {string} apikey - The apikey obtained from Gavagai developer portal
@param {object} options (optional) - optional config for the REST client
- @member {string} host - host for the Gavagai REST API (default: api.gavagai.se)
- @member {string} apiVersion - the Gavagai REST API version to use for requests (default: v3)
The Gavagai REST API client