lib/confluence.js
function Confluence(config) {
    if (!(this instanceof Confluence)) return new Confluence(config);

    if (!config) {
        throw new Error("Confluence module expects a config object.");
    }
    else if (!config.username || ! config.password) {
        throw new Error("Confluence module expects a config object with both a username and password.");
    }
    else if (!config.baseUrl) {
        throw new Error("Confluence module expects a config object with a baseUrl.");
    }

    this.config = config;

    this.config.apiPath = '/rest/api';
    this.config.extension = ''; // no extension by default

    if (this.config.version && this.config.version === 4) {
        this.config.apiPath = '/rest/prototype/latest';
        this.config.extension = '.json';
    }
}
function Confluence(config) {
    if (!(this instanceof Confluence)) return new Confluence(config);

    if (!config) {
        throw new Error("Confluence module expects a config object.");
    }
    else if (!config.username || ! config.password) {
        throw new Error("Confluence module expects a config object with both a username and password.");
    }
    else if (!config.baseUrl) {
        throw new Error("Confluence module expects a config object with a baseUrl.");
    }

    this.config = config;

    this.config.apiPath = '/rest/api';
    this.config.extension = ''; // no extension by default

    if (this.config.version && this.config.version === 4) {
        this.config.apiPath = '/rest/prototype/latest';
        this.config.extension = '.json';
    }
}
function Confluence ( config ) { if ( ! ( this instanceof Confluence ) ) return new Confluence ( config ) ; if ( ! config ) { throw new Error ( "Confluence module expects a config object." ) ; } else if ( ! config . username || ! config . password ) { throw new Error ( "Confluence module expects a config object with both a username and password." ) ; } else if ( ! config . baseUrl ) { throw new Error ( "Confluence module expects a config object with a baseUrl." ) ; } this . config = config ; this . config . apiPath = '/rest/api' ; this . config . extension = '' ; // no extension by default if ( this . config . version && this . config . version === 4 ) { this . config . apiPath = '/rest/prototype/latest' ; this . config . extension = '.json' ; } }
Construct Confluence.

@constructor
@this {Confluence}
@param {Object} config
@param {string} config.username
@param {string} config.password
@param {string} config.baseUrl
@param {number} config.version - Optional
Construct Confluence .