<commit_before>'use strict';

var request = require('request');
var Promise = require('promise');

function addRequestHeaders(headers, config) {
  // JSON formatted authentication header (XML format allowed as well)
  var dsAuthHeader = JSON.stringify({
    'Username': config.email,
    'Password': <PASSWORD>,
    'IntegratorKey': config.integratorKey
  });

  // DocuSign authorization header
  headers['X-DocuSign-Authentication'] = dsAuthHeader;
}

function initializeRequest(url, method, body, config) {
  var options = {
    'method': method,
    'uri': url,
    'body': JSON.stringify(body),
    'headers': {}
  };

  addRequestHeaders(options.headers, config);

  return options;
}

function parseResponseBody(error, response) {
  if (response.statusCode !== 200 && response.statusCode !== 201) { // success statuses
    return false;
  }
  return true;
}

function Helper(config) {
  this.config = config;
}

Helper.prototype.get = function(url, body, method) {
  var self = this;

  return new Promise(function (fulfill, reject) {
    // set request url, method, body, and headers
    var options = initializeRequest(url, method, body, self.config);

    // send the request...
    request(options, function (error, response, body) {
      var parsedBody = JSON.parse(body);

      if (!parseResponseBody(error, response)) {
        reject(parsedBody);
        return;
      }

      fulfill(parsedBody);
    });
  });
};

module.exports = Helper;
<commit_msg>Minor refactor of Helper file<commit_after>'use strict';

var request = require('request');
var Promise = require('promise');

function addRequestHeaders(headers, config) {
  // JSON formatted authentication header (XML format allowed as well)
  var dsAuthHeader = JSON.stringify({
    'Username': config.email,
    'Password': <PASSWORD>,
    'IntegratorKey': config.integratorKey
  });

  // DocuSign authorization header
  headers['X-DocuSign-Authentication'] = dsAuthHeader;
}

function initializeRequest(url, method, body, config) {
  var options = {
    'method': method,
    'uri': url,
    'body': JSON.stringify(body),
    'headers': {}
  };

  addRequestHeaders(options.headers, config);

  return options;
}

function Helper(config) {
  this.config = config;
}

Helper.prototype.get = function(url, body, method) {
  var self = this;

  return new Promise(function (fulfill, reject) {
    var requestParams = initializeRequest(url, method, body, self.config);

    request(requestParams, function (error, response, body) {
      var parsedBody = JSON.parse(body);

      if (response.statusCode !== 200 && response.statusCode !== 201) {
        reject(parsedBody);
        return;
      }

      fulfill(parsedBody);
    });
  });
};

module.exports = Helper;

{'fraction_non_alphanumeric': 0.13384390955506928, 'fraction_numerical': 0.00437636761487965, 'mean_word_length': 3.6491525423728812, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5780310', 'n_tokens_mistral': 824, 'n_tokens_neox': 799, 'n_words': 210}