<commit_before>var request = require('request');
var queryString = require('query-string');

const baseUrl = 'http://api.glassdoor.com/api/api.htm?';

var Glassdoor = function(opts){
    this.partnerId = opts.partnerId;
    this.partnerKey = opts.partnerKey;
    this.userIp = opts.userIp || "0.0.0.0";
    this.format = opts.format || "json";
    this.useragent = opts.useragent || "";
    return this;
}

Glassdoor.prototype.call = function(params, callback) {
	const promise = new Promise(
		function(resolve, reject){
   		var queryParams = "?" + queryString.stringify(params);
		 	request.get(baseUrl + queryParams, function(error, response, body) {
		 		 if (error) return reject(error);
		          const data = JSON.parse(body);
		          resolve(data);
		 		}
	 		);
		}
	);

    if (typeof callback === 'function') {
        promise.then(
        	function(res){
        		callback(null, res)
        	})
        .catch(callback);
      return null;
    }
    return promise;
};

Glassdoor.prototype.searchJobs = function(keyword, userParams, callback){
	params["q"] = keyword;
	params["action"] = "employers";
	params["t.p"] = this.partnerId;
	params["t.k"] = this.partnerKey;
	params["city"] = userParams.city;
	params["state"] = userParams.state;
	params["country"] = userParams.country;
	params["pn"] = userParams.pageNumber;
	params["ps"] = userParams.pageSize;
	return this.call(params, callback);
};

module.exports.initGlassdoor = function(opts) {
  return new Glassdoor(opts);
};<commit_msg>Finish searchCompanyByKeyword<commit_after>var request = require('request');
var queryString = require('query-string');

const baseUrl = 'http://api.glassdoor.com/api/api.htm?';

var Glassdoor = function(opts){
    this.partnerId = opts.partnerId;
    this.partnerKey = opts.partnerKey;
    this.userIp = opts.userIp || "0.0.0.0";
    this.format = opts.format || "json";
    this.useragent = opts.useragent || "";
    this.params = {};
    this.version = 1;
    return this;
}

Glassdoor.prototype.call = function(params, parser, callback) {
    const promise = new Promise(
        function(resolve, reject){
            var queryParams = queryString.stringify(params);
            request.get(baseUrl + queryParams, function(error, response, body) {
                    if (error) return reject(error);
                    const data = parser(JSON.parse(body));
                    resolve(data);
                }
            );
        }
    );

    if (typeof callback === 'function') {
        promise.then(
            function(res){
                callback(null, res)
            })
            .catch(callback);
        return null;
    }
    return promise;
};

Glassdoor.prototype.searchCompanyByKeyword = function(keyword, userParams, callback){
    this.params["q"] = keyword;
    this.params["action"] = "employers";
    this.params["t.p"] = this.partnerId;
    this.params["t.k"] = this.partnerKey;
    this.params["format"] = this.format;
    this.params["v"] = this.version;
    this.params["ps"] = 1;
    if(userParams.city !== undefined){
        this.params["city"] = userParams.city;
    }
    if(userParams.state !== undefined){
        this.params["state"] = userParams.state;
    }
    if(userParams.country !== undefined){
        this.params["country"] = userParams.country;
    }
    return this.call(this.params, getFirstEmployer, callback);
};

function getFirstEmployer(json){
    "use strict";
    var result = json.response;
    return result.employers.length >= 1 ? result.employers[0] : result.employers;
}

module.exports.initGlassdoor = function(opts) {
    return new Glassdoor(opts);
};
{'fraction_non_alphanumeric': 0.15008246289169874, 'fraction_numerical': 0.003298515667949423, 'mean_word_length': 2.9045064377682404, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '1008744', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1119, 'n_words': 214}