<commit_before>var utils = require('./utils');
var http = require('http');
var https = require('https');
var path = require('path');
var when = require('when');

function ZipmentsResource(zipments) {

  this._zipments = zipments;
  this.basePath = utils.makeURLInterpolator(zipments.getApiField('basePath'));
}

ZipmentsResource.prototype = {
  
  path: 'customer/jobs',

  initialize: function() {},

  createFullPath: function(commandPath, urlData) {
    return path.join(
      this.basePath(urlData),
      this.path,
      typeof commandPath == 'function' ?
        commandPath(urlData) : commandPath
    ).replace(/\\/g, '/'); // ugly workaround for Windows
  },

  create: function (data) {
    var self = this;
    var args = [].slice.call(arguments);

    var callback = typeof args[args.length - 1] == 'function' && args.pop();
    var deferred = this.createDeferred(callback);

    this._request('POST', this.path, data, null, function(err, response) {
      if (err) {
        deferred.reject(err);
      } else {
        deferred.resolve(response);
      }
    });

    return deferred.promise;
  },

  createDeferred: function(callback) {
      var deferred = when.defer();

      if (callback) {
        // Callback, if provided, is a simply translated to Promise'esque:
        // (Ensure callback is called outside of promise stack)
        deferred.promise.then(function(res) {
          setTimeout(function(){ callback(null, res) }, 0);
        }, function(err) {
          setTimeout(function(){ callback(err, null); }, 0);
        });
      }

      return deferred;
  },
    
  _request: function(method, path, data, auth, callback) {

    var requestData = utils.stringifyRequestData(data || {});
    var self = this;

    // var apiVersion = this._zipments.getApiField('version');
    var headers = {
      'Authorization': 'Bearer ' + this._zipments.getApiKey('auth'),
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    };

    // if (apiVersion) {
    //   headers['Stripe-Version'] = apiVersion;
    // }

    // make the request!
    makeRequest();
    

    function makeRequest() {

      var timeout = self._zipments.getApiField('timeout');
      // var isInsecureConnection = self._zipments.getApiField('protocol') == 'http';

      var req = (https
      ).request({
        host: self._zipments.getApiField('host'),
        port: self._zipments.getApiField('port'),
        path: path,
        method: method,
        headers: headers,
        ciphers: "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5"
      });<commit_msg>fixed typo<commit_after>var utils = require('./utils');
var http = require('http');
var https = require('https');
var path = require('path');
var when = require('when');

function ZipmentsResource(zipments) {

  this._zipments = zipments;
  this.basePath = utils.makeURLInterpolator(zipments.getApiField('basePath'));
}

ZipmentsResource.prototype = {
  
  path: 'customer/jobs',

  initialize: function() {},

  createFullPath: function(commandPath, urlData) {
    return path.join(
      this.basePath(urlData),
      this.path,
      typeof commandPath == 'function' ?
        commandPath(urlData) : commandPath
    ).replace(/\\/g, '/'); // ugly workaround for Windows
  },

  create: function (data) {
    var self = this;
    var args = [].slice.call(arguments);

    var callback = typeof args[args.length - 1] == 'function' && args.pop();
    var deferred = this.createDeferred(callback);

    this._request('POST', this.path, data, null, function(err, response) {
      if (err) {
        deferred.reject(err);
      } else {
        deferred.resolve(response);
      }
    });

    return deferred.promise;
  },

  createDeferred: function(callback) {
      var deferred = when.defer();

      if (callback) {
        // Callback, if provided, is a simply translated to Promise'esque:
        // (Ensure callback is called outside of promise stack)
        deferred.promise.then(function(res) {
          setTimeout(function(){ callback(null, res) }, 0);
        }, function(err) {
          setTimeout(function(){ callback(err, null); }, 0);
        });
      }

      return deferred;
  },
    
  _request: function(method, path, data, auth, callback) {

    var requestData = utils.stringifyRequestData(data || {});
    var self = this;

    // var apiVersion = this._zipments.getApiField('version');
    var headers = {
      'Authorization': 'Bearer ' + this._zipments.getApiField('auth'),
      'Accept': 'application/json',
      'Content-Type': 'application/json'
    };

    // if (apiVersion) {
    //   headers['Stripe-Version'] = apiVersion;
    // }

    // make the request!
    makeRequest();
    

    function makeRequest() {

      var timeout = self._zipments.getApiField('timeout');
      // var isInsecureConnection = self._zipments.getApiField('protocol') == 'http';

      var req = (https
      ).request({
        host: self._zipments.getApiField('host'),
        port: self._zipments.getApiField('port'),
        path: path,
        method: method,
        headers: headers,
        ciphers: "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2:!MD5"
      });
{'fraction_non_alphanumeric': 0.15078291127005605, 'fraction_numerical': 0.0019331142470520007, 'mean_word_length': 2.7821637426900585, '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': '3359020', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1532, 'n_words': 337}