<commit_before>var consumer_key;
var POCKET = {
	_createParams: function(consumer_key, access_token, obj) {
		obj = obj || {};
		obj.consumer_key = consumer_key;
		obj.access_token = access_token;
		return obj;
	},
	_request: function(method, url, data, callback) {
		var xhr = new XMLHttpRequest();

		xhr.open(method?method:"GET", url, true);

		xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
		xhr.setRequestHeader("X-Accept", "application/json");
		xhr.send(JSON.stringify(data));

		xhr.onreadystatechange = function() {
			if( xhr.readyState === xhr.DONE ) {
				try {
					callback(null, JSON.parse(xhr.responseText));
				} catch (e) {
					callback(e, null);
				}
			}
		}
	},
	add: function(consumer_key, access_token, params, callback) {
		// source: http://getpocket.com/developer/docs/v3/add
		// TODO
	},
	modify: function(consumer_key, access_token, params, callback) {
		// source: http://getpocket.com/developer/docs/v3/modify
		// TODO
	},
	RETRIEVE_URI: "https://getpocket.com/v3/get",
	retrieve: function(consumer_key, access_token, params, callback) {
		// source: http://getpocket.com/developer/docs/v3/retrieve
		if(typeof params === "function") {
			callback = params;
			params = {};
		}
		POCKET._request(
			"POST",
			POCKET.RETRIEVE_URI,
			POCKET._createParams(consumer_key, access_token, params),
			function(err, data) {
				callback(err, data.status, data.list); // TODO remove status and send err instead
			});
	},
	auth: {
		REQUEST_URI: "https://getpocket.com/v3/oauth/request",
		request: function(consumer_key, redirect_uri, callback) {
			POCKET._request(
				"POST",
				POCKET.auth.REQUEST_URI,
				{
					"consumer_key": consumer_key,
					"redirect_uri": redirect_uri
				},
				function(err, data) {
					// TODO error treatment
					callback(err, data.code);
				});
		},
		AUTHORIZE_URI: "https://getpocket.com/v3/oauth/authorize",
		authorize: function(consumer_key, request_token, callback) {
			POCKET._request(
				"POST",
				POCKET.auth.AUTHORIZE_URI,
				{
					"consumer_key": consumer_key,
					"code": request_token
				},
				function(err, data) {
					// TODO error treatment
					callback(err, data.access_token, data.username);
				});
		},
		G_AUTHORIZE_URI: "https://getpocket.com/auth/authorize",
		getAuthorizeURL: function(token, redirectUrl) {
			return POCKET.auth.G_AUTHORIZE_URI+"?request_token="+token+"&redirect_uri="+redirectUrl;
		}
	},
	STATE: {
		ALL: "all",
		UNREAD: "unread",<commit_msg>Corrected some bugs regarding faulty messages.<commit_after>var consumer_key;
var POCKET = {
	_createParams: function(consumer_key, access_token, obj) {
		obj = obj || {};
		obj.consumer_key = consumer_key;
		obj.access_token = access_token;
		return obj;
	},
	_request: function(method, url, data, callback) {
		var xhr = new XMLHttpRequest();

		xhr.open(method?method:"GET", url, true);

		xhr.setRequestHeader("Content-Type", "application/json; charset=UTF-8");
		xhr.setRequestHeader("X-Accept", "application/json");
		xhr.send(JSON.stringify(data));

		xhr.onreadystatechange = function() {
			if( xhr.readyState === xhr.DONE ) {
				var response, err;
				try {
					response = JSON.parse(xhr.responseText);
				} catch (e) {
					err = e;
				}
				callback(err, response);
			}
		}
	},
	add: function(consumer_key, access_token, params, callback) {
		// source: http://getpocket.com/developer/docs/v3/add
		// TODO
	},
	modify: function(consumer_key, access_token, params, callback) {
		// source: http://getpocket.com/developer/docs/v3/modify
		// TODO
	},
	RETRIEVE_URI: "https://getpocket.com/v3/get",
	retrieve: function(consumer_key, access_token, params, callback) {
		// source: http://getpocket.com/developer/docs/v3/retrieve
		if(typeof params === "function") {
			callback = params;
			params = {};
		}
		POCKET._request(
			"POST",
			POCKET.RETRIEVE_URI,
			POCKET._createParams(consumer_key, access_token, params),
			function(err, data) {
				if(err) {
					callback(err);
				} else {
					callback(null, data.status, data.list);
				}
			});
	},
	auth: {
		REQUEST_URI: "https://getpocket.com/v3/oauth/request",
		request: function(consumer_key, redirect_uri, callback) {
			POCKET._request(
				"POST",
				POCKET.auth.REQUEST_URI,
				{
					"consumer_key": consumer_key,
					"redirect_uri": redirect_uri
				},
				function(err, data) {
					if(err) {
						callback(err);
					} else {
						callback(null, data.code);
					}
				});
		},
		AUTHORIZE_URI: "https://getpocket.com/v3/oauth/authorize",
		authorize: function(consumer_key, request_token, callback) {
			POCKET._request(
				"POST",
				POCKET.auth.AUTHORIZE_URI,
				{
					"consumer_key": consumer_key,
					"code": request_token
				},
				function(err, data, url) {
					if(err) {
						callback(err);
					}else{
						callback(null, data.access_token, data.username);
					}
				});
		},
		G_AUTHORIZE_URI: "https://getpocket.com/auth/authorize",
		getAuthorizeURL: function(token, redirectUrl) {
			return POCKET.auth.G_AUTHORIZE_URI+"?request_token="+token+"&redirect_uri="+redirectUrl;
		}
	},
	STATE: {
		ALL: "all",
		UNREAD: "unread",
{'fraction_non_alphanumeric': 0.1537711946988891, 'fraction_numerical': 0.002728512960436562, 'mean_word_length': 3.5415929203539824, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, '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': '4167087', 'n_tokens_mistral': 2187, 'n_tokens_neox': 1820, 'n_words': 304}