<commit_before>'use strict';

var request = require('request');
var queryString = require('querystring');
var apiConfig = require('./api.json');

function HelpScoutDocs(apiKey) {

  if (!(this instanceof HelpScoutDocs)) { return new HelpScoutDocs(apiKey); }

  if (!apiKey) { throw new Error('Please provide Help Scout Docs API key!'); }

  for (var section in apiConfig.endpoints) {
    this[section] = {};
    for (var method in apiConfig.endpoints[section]) {
      this[section][method] = function(reqParams){
        return makeRequest.bind(null, reqParams);
      }(apiConfig.endpoints[section][method]);
    }
  }

  function makeRequest(reqParams, data, callback) {

    if (typeof data == 'function') {
      callback = data;
      data = {};
    } else if (typeof data == 'undefined' && typeof callback == 'undefined') {
      data = {};
      callback = function(){};
    }

    var requestOptions = {
      method: reqParams.method,<commit_msg>added comments to non-obvious code<commit_after>'use strict';

var request = require('request');
var queryString = require('querystring');
var apiConfig = require('./api.json');

function HelpScoutDocs(apiKey) {

  if (!(this instanceof HelpScoutDocs)) { return new HelpScoutDocs(apiKey); }

  if (!apiKey) { throw new Error('Please provide Help Scout Docs API key!'); }

  // create endpoints objects and methods
  for (var section in apiConfig.endpoints) {
    this[section] = {};
    for (var method in apiConfig.endpoints[section]) {
      this[section][method] = function(reqParams){
        // bind default params (URI, HTTP request method) for each method
        return makeRequest.bind(null, reqParams);
      }(apiConfig.endpoints[section][method]);
    }
  }

  // unified function to perform API call
  function makeRequest(reqParams, data, callback) {

    if (typeof data == 'function') {
      callback = data;
      data = {};
    } else if (typeof data == 'undefined' && typeof callback == 'undefined') {
      data = {};
      callback = function(){};
    }

    var requestOptions = {
      method: reqParams.method,
{'fraction_non_alphanumeric': 0.13773314203730272, 'fraction_numerical': 0.0, 'mean_word_length': 3.4892703862660945, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5839291', 'n_tokens_mistral': 607, 'n_tokens_neox': 586, 'n_words': 172}