index.js
function(apiKey, host, port, reqOpts) {
	var iod = this

	if (_.isObject(host)) {
		reqOpts = host
		host = null
	}
	else if (_.isObject(port)) {
		reqOpts = port
		port = null
	}

	if (!apiKey) throw Error('IOD apiKey is missing!')
	else if (host && !url.parse(host, false, true).protocol) {
		throw Error('Protocol not found on host: ' + host)
	}

	var httpHost = 'http://api.idolondemand.com'
	var httpsHost = 'https://api.idolondemand.com'
	var httpPort = 80
	var httpsPort = 443

	// If Https port point to Https host and vice versa
	if (host == null && port === httpsPort) host = httpsHost
	else if (host == null && port === httpPort) host = httpHost
	else if (port == null && host && host.toLowerCase() === httpsHost) port = httpsPort
	else if (port == null && host && host.toLowerCase() === httpHost) port = httpPort

	iod.apiKey = apiKey
	iod.host = host || httpsHost
	iod.port = port || httpsPort
	iod.reqOpts = _.defaults(reqOpts || {}, { timeout: 300000 })
	iod.ACTIONS = _.cloneDeep(CONSTANTS.ACTIONS)
	iod.eventEmitter = eventEmitter

	SchemaU.initSchemas(iod)

	_.bindAll.apply(_, [iod].concat(_.functions(IOD.prototype)))
}
function(apiKey, host, port, reqOpts) {
	var iod = this

	if (_.isObject(host)) {
		reqOpts = host
		host = null
	}
	else if (_.isObject(port)) {
		reqOpts = port
		port = null
	}

	if (!apiKey) throw Error('IOD apiKey is missing!')
	else if (host && !url.parse(host, false, true).protocol) {
		throw Error('Protocol not found on host: ' + host)
	}

	var httpHost = 'http://api.idolondemand.com'
	var httpsHost = 'https://api.idolondemand.com'
	var httpPort = 80
	var httpsPort = 443

	// If Https port point to Https host and vice versa
	if (host == null && port === httpsPort) host = httpsHost
	else if (host == null && port === httpPort) host = httpHost
	else if (port == null && host && host.toLowerCase() === httpsHost) port = httpsPort
	else if (port == null && host && host.toLowerCase() === httpHost) port = httpPort

	iod.apiKey = apiKey
	iod.host = host || httpsHost
	iod.port = port || httpsPort
	iod.reqOpts = _.defaults(reqOpts || {}, { timeout: 300000 })
	iod.ACTIONS = _.cloneDeep(CONSTANTS.ACTIONS)
	iod.eventEmitter = eventEmitter

	SchemaU.initSchemas(iod)

	_.bindAll.apply(_, [iod].concat(_.functions(IOD.prototype)))
}
function ( apiKey , host , port , reqOpts ) { var iod = this if ( _ . isObject ( host ) ) { reqOpts = host host = null } else if ( _ . isObject ( port ) ) { reqOpts = port port = null } if ( ! apiKey ) throw Error ( 'IOD apiKey is missing!' ) else if ( host && ! url . parse ( host , false , true ) . protocol ) { throw Error ( 'Protocol not found on host: ' + host ) } var httpHost = 'http://api.idolondemand.com' var httpsHost = 'https://api.idolondemand.com' var httpPort = 80 var httpsPort = 443 // If Https port point to Https host and vice versa if ( host == null && port === httpsPort ) host = httpsHost else if ( host == null && port === httpPort ) host = httpHost else if ( port == null && host && host . toLowerCase ( ) === httpsHost ) port = httpsPort else if ( port == null && host && host . toLowerCase ( ) === httpHost ) port = httpPort iod . apiKey = apiKey iod . host = host || httpsHost iod . port = port || httpsPort iod . reqOpts = _ . defaults ( reqOpts || { } , { timeout : 300000 } ) iod . ACTIONS = _ . cloneDeep ( CONSTANTS . ACTIONS ) iod . eventEmitter = eventEmitter SchemaU . initSchemas ( iod ) _ . bindAll . apply ( _ , [ iod ] . concat ( _ . functions ( IOD . prototype ) ) ) }
Creates a IOD object with specified apiKey, host and port.

@param {String} apiKey - Api key
@param {String} [host] - IOD host
@param {Integer | null} [port] - IOD port
@param {Integer} [reqOpts] - Request options
@property {String} apiKey - Api key
@property {String} host - IOD host
@property {Integer} port - IOD port
@property {Object} reqOpts - Request options
@constructor
@throws {Error}
If api key does not exists.
If host does not contain protocol
Creates a IOD object with specified apiKey host and port .