<commit_before>module.exports = {
	login: login,
	getSubscriptions: getSubscriptions,
	getReleases: getReleases
};

var request = require('request'),
	Q = require('q'),

	urls = require('./endpoints');

var loginPromise = null;

function login(email, password) {
	if(loginPromise) return loginPromise;

	return loginPromise = Q.Promise(function(resolve, reject, notify) {
		request.post({
			url: urls.login,
			json: { email: email, password: password },
			strictSSL: true
		}, function loginCb(err, msg, body) {
			if(!err && !body.errors) {
				var loginCookie = msg.headers['set-cookie'];
				var userData = body;

				resolve({
					data: userData,
					cookie: loginCookie
				});
			}
			else {
				reject(err || body.errors);
			}
		});
	});
}

function getSubscriptions() {
	return login()
	.then(function(res) {
		return res.data.memberships;
	}, function(err) { throw err; });
}

function getReleases(subscription) {
	return Q.promise(function(resolve, reject) {
		login()
		.then(function(res) {
			var url = urls.releases(subscription.creative);
			request.get({
				url: url,
				json: true,
				strictSSL: true,
				headers: { "cookie": res.cookie }
			}, function getReleasesCb(err, msg, body) {
				if(err) {
					reject(err);
				}
				else if(msg.statusCode >= 400) {
					reject("HTTP Error " + msg.statusCode + " at " + url);
				}
				else {
					resolve(body);
				}
			});
		});
	});
}<commit_msg>Reformat if-else in getReleases<commit_after>module.exports = {
	login: login,
	getSubscriptions: getSubscriptions,
	getReleases: getReleases
};

var request = require('request'),
	Q = require('q'),

	urls = require('./endpoints');

var loginPromise = null;

function login(email, password) {
	if(loginPromise) return loginPromise;

	return loginPromise = Q.Promise(function(resolve, reject, notify) {
		request.post({
			url: urls.login,
			json: { email: email, password: password },
			strictSSL: true
		}, function loginCb(err, msg, body) {
			if(!err && !body.errors) {
				var loginCookie = msg.headers['set-cookie'];
				var userData = body;

				resolve({
					data: userData,
					cookie: loginCookie
				});
			}
			else {
				reject(err || body.errors);
			}
		});
	});
}

function getSubscriptions() {
	return login()
	.then(function(res) {
		return res.data.memberships;
	}, function(err) { throw err; });
}

function getReleases(subscription) {
	return Q.promise(function(resolve, reject) {
		login()
		.then(function(res) {
			var url = urls.releases(subscription.creative);
			request.get({
				url: url,
				json: true,
				strictSSL: true,
				headers: { "cookie": res.cookie }
			}, function getReleasesCb(err, msg, body) {
				if(!err && msg.statusCode < 400) {
					resolve(body);
				}
				else {
					reject(err || "HTTP Error " + msg.statusCode + " at " + url);
				}
			});
		});
	});
}
{'fraction_non_alphanumeric': 0.15531238969290503, 'fraction_numerical': 0.002117896223085069, 'mean_word_length': 3.300455235204856, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '5352756', 'n_tokens_mistral': 1143, 'n_tokens_neox': 951, 'n_words': 210}