//
// Module: Templates
// =================
//
'use strict';

//
// <a name='constructor'></a>
// Constructor
// -----------
//
function Templates (opts, uri) {
  ['key', 'secret'].forEach(function (item) {
    if (opts[item] == null)
      throw new Error('There\'s a required argument missing: ' + item);
  });

  this.opts = opts;
  this.uri = uri;
}

//
// <a name='create'></a>
// Create a template
// -----------------
//
// #### Arguments
//
// + `params` -- Required
//   - `template`
//   - `auth` is required as well but this is created together with the signature
//   before doing the `POST` request inside this method.
// + `callback` - Function Callback
//
// #### Returns
//
// A `Callback` function with `(err, body)` from the request.
//
// #### Code
Templates.prototype.create = function (params, callback) {
  var self = this;
  var signature = new (require('./signature.js'))(self.opts);
  var request = require('request');
  var r = request.post(
    self.uri.base + self.uri.templates,
    function (err, response, body) {
      if (err)
        return callback(err);

      return callback(null, body);
  });

  var form = r.form();

  var x = signature.create(params);

  form.append('signature', x.signature);
  form.append('params', JSON.stringify(x.params));
};

module.exports = Templates;

@@ -1284,16 +1284,983 @@
 ));%0A%7D;%0A%0A
+//%0A// %3Ca name='edit'%3E%3C/a%3E%0A// Edit a template%0A// ---------------%0A//%0A// #### Arguments%0A//%0A// + %60params%60 -- Required%0A//   - %60name%60%0A//   - %60template%60%0A//   - %60auth%60 is required as well but this is created together with the signature%0A//   before doing the %60PUT%60 request inside this method.%0A// + %60callback%60 - Function Callback%0A//%0A// #### Returns%0A//%0A// A %60Callback%60 function with %60(err, body)%60 from the request%0A//%0A// #### Code%0ATemplates.prototype.edit = function (params, templateId, callback) %7B%0A  var self = this;%0A  var signature = new (require('./signature.js'))(self.opts);%0A  var request = require('request');%0A%0A  var x = signature.create(params);%0A  var payload = %7B%0A    params: x.params,%0A    signature: x.signature%0A  %7D;%0A%0A  request(%7B%0A    method: 'PUT',%0A    uri: self.uri.base + self.uri.templates + '/' + templateId,%0A    body: JSON.stringify(payload)%0A  %7D, function (err, response, body) %7B%0A    if (err)%0A      return callback(err);%0A%0A    return callback(null, body);%0A  %7D);%0A%7D;%0A%0A
 module.e

edit method created