<commit_before>var http = require('http')
  , https = require('https')
  , url = require('url')
  , fc = require('./foodlogiq-connection');

module.exports = function(accessToken, businessId) {
  console.log('intializing locations wrapper with ' + accessToken + ','+businessId);

  if(!businessId) {
    throw new Error('cannot initialize locations wrapper without a businessId');
  }

  this.list = function(callback) {
    var conn = fc.init(accessToken);
    conn.get('/businesses/'+businessId+'/locations', function(err, locs) {
      if(err) return callback(err);
      callback(null, locs);
    });
  };

  this.create = function(location, callback) {
    var conn = fc.init(accessToken);
    conn.post('/businesses/'+businessId+'/locations', location, function(err, newLocation) {
      if(err) return callback(err);
      callback(null, newLocation);
    });
  };

  this.find = function(locationId, callback) {
    var conn = fc.init(accessToken);
    conn.get('/businesses/'+businessId+'/locations/'+locationId, function(err, foundLoc) {
      if(err) return callback(err);
      callback(null, foundLoc);
    });
  };

  this.edit = function(location, callback) {
    var conn = fc.init(accessToken);
    conn.put('/businesses/'+businessId+'/locations/'+location.foodlogiqId, location, function(err, edittedLoc) {
      if(err) return callback(err);
      callback(null, edittedLoc);
    });
  };
};<commit_msg>Location id needs to be passed in separately for the put request.<commit_after>var http = require('http')
  , https = require('https')
  , url = require('url')
  , fc = require('./foodlogiq-connection');

module.exports = function(accessToken, businessId) {
  console.log('intializing locations wrapper with ' + accessToken + ','+businessId);

  if(!businessId) {
    throw new Error('cannot initialize locations wrapper without a businessId');
  }

  this.list = function(callback) {
    var conn = fc.init(accessToken);
    conn.get('/businesses/'+businessId+'/locations', function(err, locs) {
      if(err) return callback(err);
      callback(null, locs);
    });
  };

  this.create = function(location, callback) {
    var conn = fc.init(accessToken);
    conn.post('/businesses/'+businessId+'/locations', location, function(err, newLocation) {
      if(err) return callback(err);
      callback(null, newLocation);
    });
  };

  this.find = function(locationId, callback) {
    var conn = fc.init(accessToken);
    conn.get('/businesses/'+businessId+'/locations/'+locationId, function(err, foundLoc) {
      if(err) return callback(err);
      callback(null, foundLoc);
    });
  };

  this.edit = function(locationId, location, callback) {
    var conn = fc.init(accessToken);
    conn.put('/businesses/'+businessId+'/locations/'+locationId, location, function(err, edittedLoc) {
      if(err) return callback(err);
      callback(null, edittedLoc);
    });
  };
};
{'fraction_non_alphanumeric': 0.15907522429261559, 'fraction_numerical': 0.0, 'mean_word_length': 3.9052453468697124, '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': '6625402', 'n_tokens_mistral': 899, 'n_tokens_neox': 878, 'n_words': 182}