/**
 * AcuityScheduling Class
 */

var request = require('request');

function AcuityScheduling (config) {

  config = config || {};

  this.base = config.base || AcuityScheduling.base;
  this.apiKey = config.apiKey;
  this.userId = config.userId;

  return this;
}

AcuityScheduling.base = 'https://acuityscheduling.com';

AcuityScheduling.prototype._request = function (path, options, cb) {

  options = options || {};
  if (!cb) {
    cb = (typeof options === 'function') ? options : function () {};
  }

  var config = {
    url: this.base + '/api/v1/' + path,
    json: true
  };

  if (options.auth)     config.auth     = options.auth;
  if (options.body)     config.body     = options.body;
  if (options.headers)  config.headers  = options.headers;
  if (options.method)   config.method   = options.method;
  if (options.qs)       config.qs       = options.qs;

  return request(config, function (err, response, body) {
    if (err) return cb(err, response, body);
    cb(err, response, body);
  });
};

AcuityScheduling.prototype.request = function (path, options, cb) {
  options = options || {};
  options.auth = options.auth || {
    user: this.userId + '',
    pass: this.apiKey
  };
  return this._request(path, options, cb);
};

module.exports = AcuityScheduling;


@@ -61,16 +61,49 @@
 quest');
+%0Avar pkg = require('../package');
 %0A%0Afuncti
@@ -612,16 +612,47 @@
 e%0A  %7D;%0A%0A
+  // Set configurable options:%0A
   if (op
@@ -773,16 +773,16 @@
 ons.
-headers)
+method) 
   co
@@ -786,23 +786,23 @@
  config.
-headers
+method 
   = opti
@@ -809,15 +809,14 @@
 ons.
-headers
+method
 ;%0A  
@@ -819,39 +819,39 @@
 ;%0A  if (options.
-method)
+qs)    
    config.method
@@ -836,38 +836,38 @@
 s)       config.
-method
+qs    
    = options.met
@@ -867,68 +867,146 @@
 ons.
-method;%0A  if (options.qs)       config.qs       = options.qs
+qs;%0A  config.headers =      options.headers %7C%7C %7B%7D;%0A%0A  // User agent:%0A  config.headers%5B'User-Agent'%5D = 'AcuityScheduling-js/' + pkg.version
 ;%0A%0A 

Add user agent and version.