<commit_before>/**
 * Created by michael on 2/5/15.
 */



var sparkPrint = function () {

	var serverUrl = "https://api-alpha.spark.autodesk.com/api/v1/"

	/**
	 * Return the factory object
	 */
	return {


		registerPrinter: function (token,printerName,callback,errorCallback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {

				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};

				var url = serverUrl + "print/printers/register"
				Util.xhr(url, 'POST', "registration_code="+token+"&printer_name="+printerName, headers, callback,errorCallback);
			}else{
				callback(false);
			}

		},


		getAllPrinters: function (callback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};
				Util.xhr(serverUrl + 'print/printers', 'GET', '', headers, callback);
			}else{
				callback(false);
			}

		},

		printJob: function (fileUrl, printerId,settings,callback,errorCallback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {

				var params =JSON.stringify( {printable_id:fileUrl,settings:settings});
				//var params = {printable_id:fileUrl,settings:settings};
				console.log(params);
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/json"
				};
				var url = serverUrl + 'print/printers/'+printerId+"/jobs";
				Util.xhr(url, 'POST', params, headers, callback,errorCallback);
			}else{
				callback(false);
			}

		},

		/**
		 * Create a new asset
		 * @param assetPost
		 */
		getJobsStatusByPrinter: function (printerId,callback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};
				Util.xhr(serverUrl + 'print/printers/' + printerId + "/jobs", 'GET', '', headers, callback);
			}else{
				callback(false);
			}

		},

		sendPrintCommand: function(printerID,jobId,command,callback,errorCallback){
			if (sparkAuth.isTokenValid()) {
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};
				Util.xhr(serverUrl + 'print/printers/' + printerID + "/command", 'POST', 'command='+command+"&job_id="+jobId, headers, callback);
			}else{
				callback(false);
			}

		}
	}


}();<commit_msg>added comments to print sdk<commit_after>/**
 * Created by michael on 2/5/15.
 */



var sparkPrint = function () {

	var serverUrl = "https://api-alpha.spark.autodesk.com/api/v1/"

	/**
	 * Return the factory object
	 */
	return {


		/**
		 * Registers a printer for the logged in user.
		 * @param printerName
		 * @param callback
		 * @param errorCallback
		 */
		registerPrinter: function (token, printerName,callback,errorCallback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {

				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};

				var url = serverUrl + "print/printers/register"
				Util.xhr(url, 'POST', "registration_code="+token+"&printer_name="+printerName, headers, callback,errorCallback);
			}else{
				callback(false);
			}

		},


		/**
		 * Gets all printer that are registered to the logged in user
		 * @param callback
		 * @param errorCallback
		 */
		getAllPrinters: function (callback,errorCallback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};
				Util.xhr(serverUrl + 'print/printers', 'GET', '', headers, callback,errorCallback);
			}else{
				callback(false);
			}

		},

		/**
		 * Sends a print job
		 * @param printableId
		 * @param printerId
		 * @param settings
		 * @param callback
		 * @param errorCallback
		 */
		printJob: function (printableId, printerId,settings,callback,errorCallback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {

				var params =JSON.stringify( {printable_id:printableId,settings:settings});
				//var params = {printable_id:fileUrl,settings:settings};
				console.log(params);
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/json"
				};
				var url = serverUrl + 'print/printers/'+printerId+"/jobs";
				Util.xhr(url, 'POST', params, headers, callback,errorCallback);
			}else{
				callback(false);
			}

		},

		/**
		 * Returns all job statuses for printer specified by printerId
		 * @param printerId
		 * @param callback
		 * @param errorCallback
		 */
		getJobsStatusByPrinter: function (printerId,callback,errorCallback) {
			//Make sure token is still valid
			if (sparkAuth.isTokenValid()) {
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};
				Util.xhr(serverUrl + 'print/printers/' + printerId + "/jobs", 'GET', '', headers, callback,errorCallback);
			}else{
				callback(false);
			}

		},

		/**
		 * Sends a command(resume/pause/cancel) to a specific printer with specific job
		 * @param printerID
		 * @param jobId
		 * @param command - resume/pause/cancel
		 * @param callback
		 * @param errorCallback
		 */
		sendPrintCommand: function(printerID,jobId,command,callback,errorCallback){
			if (sparkAuth.isTokenValid()) {
				var headers = {
					"Authorization": "Bearer " + sparkAuth.accessToken(),
					"Content-type": "application/x-www-form-urlencoded"
				};
				Util.xhr(serverUrl + 'print/printers/' + printerID + "/command", 'POST', 'command='+command+"&job_id="+jobId, headers, callback,errorCallback);
			}else{
				callback(false);
			}

		}
	}


}();
{'fraction_non_alphanumeric': 0.14970159151193635, 'fraction_numerical': 0.0016578249336870027, 'mean_word_length': 3.3844476744186047, 'pattern_counts': {'":': 20, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '494837', 'n_tokens_mistral': 2331, 'n_tokens_neox': 1881, 'n_words': 404}