index.js
function Connect(username, password, options) {
	// Default Options
	this.options = {
		baseURL				: "https://itunesconnect.apple.com",
		apiURL				: "https://reportingitc2.apple.com/api/",
		loginURL			: "https://idmsa.apple.com/appleauth/auth/signin",
		appleWidgetKey      : "22d448248055bab0dc197c6271d738c3",
		concurrentRequests	: 2,
		errorCallback		: function(e) {},
		loginCallback		: function(c) {}
	};
	// Extend options
	_.extend(this.options, options);

	// Set cookies
	this._cookies = [];

	// Task Executor
	this._queue = async.queue(
		this.executeRequest.bind(this), 
		this.options.concurrentRequests
	);
	// Pasue queue and wait for login to complete
	this._queue.pause();

	// Login to iTunes Connect
	if(typeof this.options["cookies"] !== 'undefined') {
		this._cookies = this.options.cookies;
		this._queue.resume();
	}
	else {
		this.login(username, password);
	}
}
function Connect(username, password, options) {
	// Default Options
	this.options = {
		baseURL				: "https://itunesconnect.apple.com",
		apiURL				: "https://reportingitc2.apple.com/api/",
		loginURL			: "https://idmsa.apple.com/appleauth/auth/signin",
		appleWidgetKey      : "22d448248055bab0dc197c6271d738c3",
		concurrentRequests	: 2,
		errorCallback		: function(e) {},
		loginCallback		: function(c) {}
	};
	// Extend options
	_.extend(this.options, options);

	// Set cookies
	this._cookies = [];

	// Task Executor
	this._queue = async.queue(
		this.executeRequest.bind(this), 
		this.options.concurrentRequests
	);
	// Pasue queue and wait for login to complete
	this._queue.pause();

	// Login to iTunes Connect
	if(typeof this.options["cookies"] !== 'undefined') {
		this._cookies = this.options.cookies;
		this._queue.resume();
	}
	else {
		this.login(username, password);
	}
}
function Connect ( username , password , options ) { // Default Options this . options = { baseURL : "https://itunesconnect.apple.com" , apiURL : "https://reportingitc2.apple.com/api/" , loginURL : "https://idmsa.apple.com/appleauth/auth/signin" , appleWidgetKey : "22d448248055bab0dc197c6271d738c3" , concurrentRequests : 2 , errorCallback : function ( e ) { } , loginCallback : function ( c ) { } } ; // Extend options _ . extend ( this . options , options ) ; // Set cookies this . _cookies = [ ] ; // Task Executor this . _queue = async . queue ( this . executeRequest . bind ( this ) , this . options . concurrentRequests ) ; // Pasue queue and wait for login to complete this . _queue . pause ( ) ; // Login to iTunes Connect if ( typeof this . options [ "cookies" ] !== 'undefined' ) { this . _cookies = this . options . cookies ; this . _queue . resume ( ) ; } else { this . login ( username , password ) ; } }
Initialize a new `Connect` with the given `username`, `password` and `options`.

Examples:

// Import itc-report
var itc 	= require("itunesconnect"),
Report  = itc.Report;

// Init new iTunes Connect
var itunes = new itc.Connect('apple@id.com', 'password');

// Init new iTunes Connect
var itunes = new itc.Connect('apple@id.com', 'password', {
errorCallback: function(error) {
console.log(error);
},
concurrentRequests: 1
});

@class Connect
@constructor
@param {String} username Apple ID login
@param {String} password Apple ID password
@param {Object} [options]
@param {String} [options.baseURL] iTunes Connect Login URL
@param {String} [options.apiURL] iTunes Connect API URL
@param {Number} [options.concurrentRequests] Number of concurrent requests
@param {Array} [options.cookies] Cookies array. If you provide cookies array it will not login and use this instead.
@param {Function} [options.errorCallback] Error callback function called when requests are failing
@param {Function} [options.errorCallback.error] Login error
@param {Function} [options.loginCallback] Login callback function called when login to iTunes Connect was a success.
@param {Function} [options.loginCallback.cookies] cookies are passed as a first argument. You can get it and cache it for later.
Initialize a new Connect with the given username password and options .