APICreatorSDK.js
function (url, key, password) {
			var deferred, options, headers, liveapicreator;
			liveapicreator = _.extend({}, SDK);
			liveapicreator.url = this.stripWrappingSlashes(url);
			liveapicreator.params = _.pick(URL.parse(url), 'host', 'path', 'port');
			liveapicreator.params.headers = {};

			if (url.match('https')) {
				liveapicreator.req = https;
			}

			//passed a url with a defined port
			if (liveapicreator.isUrlWithPort(liveapicreator.params.host)) {
				liveapicreator.params.host = liveapicreator.stripUrlPort(liveapicreator.params.host);
			}
			deferred = Q.defer();
			liveapicreator.connection = deferred.promise;

			//Is this a username/password combo
			if (password) {
				options = liveapicreator.setOptions({method: 'POST'});
				options.headers['Content-Type'] ='application/json';
				options.path += liveapicreator.authEndpoint;
				var req = liveapicreator.req.request(options, function (res) {
					if (res.statusCode == 503) {
						deferred.reject(res.statusCode);
					}
					res.setEncoding('utf8');
					res.on('data', function (data) {
						data = JSON.parse(data);
						liveapicreator.apiKey = data.apikey;
						liveapicreator.params.headers.Authorization = 'CALiveAPICreator ' + data.apikey + ':1';
						deferred.resolve();
					});
				});
				req.end(JSON.stringify({username: key, password: password}));

				req.on('error', function(e) {
					deferred.reject('Authentication failed, please confirm the username and/or password');
				});
			} else {
				//liveapicreatorsdk.connect() was directly passed an API key
				liveapicreator.apiKey = key;
				liveapicreator.params.headers.Authorization = 'CALiveAPICreator ' + key + ':1';
				deferred.resolve();
			}
			return liveapicreator;
		}
function (url, key, password) {
			var deferred, options, headers, liveapicreator;
			liveapicreator = _.extend({}, SDK);
			liveapicreator.url = this.stripWrappingSlashes(url);
			liveapicreator.params = _.pick(URL.parse(url), 'host', 'path', 'port');
			liveapicreator.params.headers = {};

			if (url.match('https')) {
				liveapicreator.req = https;
			}

			//passed a url with a defined port
			if (liveapicreator.isUrlWithPort(liveapicreator.params.host)) {
				liveapicreator.params.host = liveapicreator.stripUrlPort(liveapicreator.params.host);
			}
			deferred = Q.defer();
			liveapicreator.connection = deferred.promise;

			//Is this a username/password combo
			if (password) {
				options = liveapicreator.setOptions({method: 'POST'});
				options.headers['Content-Type'] ='application/json';
				options.path += liveapicreator.authEndpoint;
				var req = liveapicreator.req.request(options, function (res) {
					if (res.statusCode == 503) {
						deferred.reject(res.statusCode);
					}
					res.setEncoding('utf8');
					res.on('data', function (data) {
						data = JSON.parse(data);
						liveapicreator.apiKey = data.apikey;
						liveapicreator.params.headers.Authorization = 'CALiveAPICreator ' + data.apikey + ':1';
						deferred.resolve();
					});
				});
				req.end(JSON.stringify({username: key, password: password}));

				req.on('error', function(e) {
					deferred.reject('Authentication failed, please confirm the username and/or password');
				});
			} else {
				//liveapicreatorsdk.connect() was directly passed an API key
				liveapicreator.apiKey = key;
				liveapicreator.params.headers.Authorization = 'CALiveAPICreator ' + key + ':1';
				deferred.resolve();
			}
			return liveapicreator;
		}
function ( url , key , password ) { var deferred , options , headers , liveapicreator ; liveapicreator = _ . extend ( { } , SDK ) ; liveapicreator . url = this . stripWrappingSlashes ( url ) ; liveapicreator . params = _ . pick ( URL . parse ( url ) , 'host' , 'path' , 'port' ) ; liveapicreator . params . headers = { } ; if ( url . match ( 'https' ) ) { liveapicreator . req = https ; } //passed a url with a defined port if ( liveapicreator . isUrlWithPort ( liveapicreator . params . host ) ) { liveapicreator . params . host = liveapicreator . stripUrlPort ( liveapicreator . params . host ) ; } deferred = Q . defer ( ) ; liveapicreator . connection = deferred . promise ; //Is this a username/password combo if ( password ) { options = liveapicreator . setOptions ( { method : 'POST' } ) ; options . headers [ 'Content-Type' ] = 'application/json' ; options . path += liveapicreator . authEndpoint ; var req = liveapicreator . req . request ( options , function ( res ) { if ( res . statusCode == 503 ) { deferred . reject ( res . statusCode ) ; } res . setEncoding ( 'utf8' ) ; res . on ( 'data' , function ( data ) { data = JSON . parse ( data ) ; liveapicreator . apiKey = data . apikey ; liveapicreator . params . headers . Authorization = 'CALiveAPICreator ' + data . apikey + ':1' ; deferred . resolve ( ) ; } ) ; } ) ; req . end ( JSON . stringify ( { username : key , password : password } ) ) ; req . on ( 'error' , function ( e ) { deferred . reject ( 'Authentication failed, please confirm the username and/or password' ) ; } ) ; } else { //liveapicreatorsdk.connect() was directly passed an API key liveapicreator . apiKey = key ; liveapicreator . params . headers . Authorization = 'CALiveAPICreator ' + key + ':1' ; deferred . resolve ( ) ; } return liveapicreator ; }
The default method of connecting to an API. Returns an instance of this library
and initializes a promise used to make requests on API endpoints.

@param string url the API url base e.g. http://localhost:8080/rest/default/demo/v1
@param string key an API key, typically found in Logic Designer's Security section.
When connecting  with a username/password, this second argument (key) is a username
When connecting with an APIKey - set the password to null or omit.
@param string password an optional argument when using liveapicreatorsdk.connect() with a user/password combination
The default method of connecting to an API . Returns an instance of this library and initializes a promise used to make requests on API endpoints .