<commit_before>function API(host, apiToken) {
  this.host = host;
  this.apiTokenEncoded = new Buffer(apiToken+':x-auth-token').toString('base64');
}

API.prototype.buildRequestUrl = function(path) {
  return this.host + '/api/v1' + path;
}

API.prototype.request = function(requester, path, method, body) {
  var headers = {
    "Authorization": 'Basic ' + this.apiTokenEncoded
  };

  if(body) {
    headers["Content-Type"] = "application/json";
  }

  return requester(
    this.buildRequestUrl(path), 
    method || "GET",
    headers,
    body
  );
}

API.prototype.getDocumentIds = function(requester, docSetId) {
  return this.request(
    requester,
    "/document-sets/" + docSetId + "/documents?fields=id"
  );
};

API.prototype.getDocument = function(requester, docId, docSetId) {
  return this.request(
    requester,
    "/document-sets/" + docSetId + "/documents/" + docId
  );
};

API.prototype.getAllDocuments = function(requester, docSetId, sort) {
  return this.request(
    requester, 
    "/document-sets/" + docSetId + "/documents?stream=true&fields=id,text&sort=" + sort
  );
}

API.prototype.getStoreState = function(requester) {
  return this.request(requester, '/store/state');
}

API.prototype.setStoreState = function(requester, state) {
  return this.request(requester, '/store/state', 'PUT', state);
}

module.exports = API;<commit_msg>API Lib: support basic StoreObject operations<commit_after>function API(host, apiToken) {
  this.host = host;
  this.apiTokenEncoded = new Buffer(apiToken+':x-auth-token').toString('base64');
}

API.prototype.buildRequestUrl = function(path) {
  return this.host + '/api/v1' + path;
}

API.prototype.request = function(requester, path, method, body) {
  var headers = {
    "Authorization": 'Basic ' + this.apiTokenEncoded
  };

  if(body) {
    headers["Content-Type"] = "application/json";
  }

  return requester(
    this.buildRequestUrl(path), 
    method || "GET",
    headers,
    body
  );
}

API.prototype.getDocumentIds = function(requester, docSetId) {
  return this.request(
    requester,
    "/document-sets/" + docSetId + "/documents?fields=id"
  );
};

API.prototype.getDocument = function(requester, docId, docSetId) {
  return this.request(
    requester,
    "/document-sets/" + docSetId + "/documents/" + docId
  );
};

API.prototype.getAllDocuments = function(requester, docSetId, sort) {
  return this.request(
    requester, 
    "/document-sets/" + docSetId + "/documents?stream=true&fields=id,text&sort=" + sort
  );
}

API.prototype.getStoreState = function(requester) {
  return this.request(requester, '/store/state');
}

API.prototype.setStoreState = function(requester, state) {
  return this.request(requester, '/store/state', 'PUT', state);
}

API.prototype.getStoreObjects = function(requester) {
  return this.request(requester, '/store/objects');
}

API.prototype.createStoreObject = function(requester, state) {
  return this.request(requester, '/store/objects', 'POST', state);
}

API.prototype.updateStoreObject = function(requester, StoreObjectId, state) {
  return this.request(requester, '/store/objects/' + StoreObjectId, 'PUT', state);
}

module.exports = API;
{'fraction_non_alphanumeric': 0.1553030303030303, 'fraction_numerical': 0.001893939393939394, 'mean_word_length': 4.229372937293729, 'pattern_counts': {'":': 2, '<': 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': '4374771', 'n_tokens_mistral': 1052, 'n_tokens_neox': 1034, 'n_words': 187}