
/**
 * Module dependencies.
 */

var debug = require('debug')('wpcom:tag');

/**
 * Tag methods
 *
 * @param {String} [slug]
 * @param {String} sid site id
 * @param {WPCOM} wpcom
 * @api public
 */

function Tag(slug, sid, wpcom){
  if (!sid) {
    throw new Error('`side id` is not correctly defined');
  }

  if (!(this instanceof Tag)) return new Tag(slug, sid, wpcom);

  this.wpcom = wpcom;
  this._sid = sid;
  this._slug = slug;
}

/**
 * Set tag `slug`
 *
 * @param {String} slug
 * @api public
 */

Tag.prototype.slug = function(slug){
  this._slug = slug;
};

/**
 * Get tag
 *
 * @param {Object} [query]
 * @param {Function} fn
 * @api public
 */

Tag.prototype.get = function(query, fn){
  var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;
  return this.wpcom.sendRequest(path, query, null, fn);
};

/**
 * Add tag
 *
 * @param {Object} body
 * @param {Function} fn
 * @api public
 */

Tag.prototype.add = function(body, fn){
  var path = '/sites/' + this._sid + '/tags/new';
  return this.wpcom.sendRequest({ path: path, method: 'post' }, null, body, fn);
};

/**
 * Edit tag
 *
 * @param {Object} body
 * @param {Function} fn
 * @api public
 */

Tag.prototype.update = function(body, fn){
  var path = '/sites/' + this._sid + '/tags/slug:' + this._slug;
  return this.wpcom.sendRequest({ path: path, method: 'post' }, null, body, fn);
};

/**
 * Delete tag
 *
 * @param {Function} fn
 * @api public
 */

Tag.prototype['delete'] =
Tag.prototype.del = function(fn){
  var path = '/sites/' + this._sid + '/tags/slug:' + this._slug + '/delete';
  return this.wpcom.sendRequest({ path: path, method: 'post' }, null, null, fn);
};

/**
 * Expose `Tag` module
 */

module.exports = Tag;

@@ -224,18 +224,19 @@
 , wpcom)
+ 
 %7B%0A
-
   if (!s
@@ -334,16 +334,22 @@
 of Tag))
+ %7B%0A   
  return 
@@ -374,16 +374,20 @@
  wpcom);
+%0A  %7D
 %0A%0A  this
@@ -547,14 +547,16 @@
 tion
+ 
 (slug)
+ 
 %7B%0A  
@@ -695,16 +695,17 @@
 function
+ 
 (query, 
@@ -703,24 +703,25 @@
  (query, fn)
+ 
 %7B%0A  var path
@@ -941,32 +941,33 @@
 e.add = function
+ 
 (body, fn)%7B%0A  va
@@ -952,32 +952,33 @@
 ction (body, fn)
+ 
 %7B%0A  var path = '
@@ -1216,16 +1216,17 @@
 function
+ 
 (body, f
@@ -1227,16 +1227,17 @@
 ody, fn)
+ 
 %7B%0A  var 
@@ -1470,17 +1470,17 @@
 lete'%5D =
-%0A
+ 
 Tag.prot
@@ -1503,12 +1503,14 @@
 tion
+ 
 (fn)
+ 
 %7B%0A  
@@ -1701,16 +1701,16 @@
 le%0A */%0A%0A
+
 module.e
@@ -1722,9 +1722,8 @@
 s = Tag;
-%0A

update coding