<commit_before>'use strict';
const BPromise = require('bluebird');

const Http = require('./http');
const config = require('./config');
const ErrorResponse = require('./errors/error_response');
const { omit } = require('./helpers');

class Resource {
  constructor(path) {
    this.http = new Http(config.namespace + path);
  }

  list(params) {
    const req = this.http.method('get').query(params);
    return this.__makeRequest(req);
  }

  __makeRequest(req) {
    return new BPromise(function (resolve, reject) {
      req.end(function (err, res) {
        if (err) {
          reject(new ErrorResponse(err));
        } else {
          resolve(res);
        }
      });
    }).catch(function (err) {
      throw err;
    });
  }

  create(params) {
    const req = this.http.method('post').send(params);
    return this.__makeRequest(req);
  }

  get(params) {
    const req = this.http.method('get').query(omit(params, 'id'));
    req.url += `/${params.id}`;
    return this.__makeRequest(req);
  }

  update(params) {
    const req = this.http.method('put').send(params);
    req.url += `/${params.id}`;<commit_msg>update will go as PATCH<commit_after>'use strict';
const BPromise = require('bluebird');

const Http = require('./http');
const config = require('./config');
const ErrorResponse = require('./errors/error_response');
const { omit } = require('./helpers');

class Resource {
  constructor(path) {
    this.http = new Http(config.namespace + path);
  }

  list(params) {
    const req = this.http.method('get').query(params);
    return this.__makeRequest(req);
  }

  __makeRequest(req) {
    return new BPromise(function (resolve, reject) {
      req.end(function (err, res) {
        if (err) {
          reject(new ErrorResponse(err));
        } else {
          resolve(res);
        }
      });
    }).catch(function (err) {
      throw err;
    });
  }

  create(params) {
    const req = this.http.method('post').send(params);
    return this.__makeRequest(req);
  }

  get(params) {
    const req = this.http.method('get').query(omit(params, 'id'));
    req.url += `/${params.id}`;
    return this.__makeRequest(req);
  }

  update(params) {
    const req = this.http.method('patch').send(omit(params, 'id'));
    req.url += `/${params.id}`;
{'fraction_non_alphanumeric': 0.17841409691629956, 'fraction_numerical': 0.0, 'mean_word_length': 2.9842105263157896, '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': '1016628', 'n_tokens_mistral': 722, 'n_tokens_neox': 719, 'n_words': 144}