
/**
 * Module dependencies.
 */

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

/**
 * Reblog methods
 *
 * @param {String} pid post id
 * @param {String} sid site id
 * @param {WPCOM} wpcom
 * @api public
 */

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

  if (!pid) {
    throw new Error('`post id` is not correctly defined');
  }

  if (!(this instanceof Reblog)) return new Reblog(pid, sid, wpcom);

  this.wpcom = wpcom;
  this._pid = pid;
  this._sid = sid;
}

/**
 * Get reblog status for a Post
 *
 * @param {Object} [query]
 * @param {Function} fn
 * @api public
 */

Reblog.prototype.mine = function(query, fn){
  var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/mine';
  this.wpcom.sendRequest(path, query, null, fn);
};

/**
 * Reblog a post
 *
 * @param {Object} body
 * @param {Function} fn
 * @api public
 */

Reblog.prototype.add = function(body, fn){
  if (body && !body.destination_site_id) {
    return fn(new Error('destination_site_id is not defined'));
  }

  var path = '/sites/' + this._sid + '/posts/' + this._pid + '/reblogs/new';
  this.wpcom.sendRequest({ path: path, method: 'post' }, null, body, fn);
};

/**
 * Expose `Reblog` module
 */

module.exports = Reblog;

@@ -630,32 +630,57 @@
 api public%0A */%0A%0A
+Reblog.prototype.state =%0A
 Reblog.prototype
@@ -1237,24 +1237,380 @@
 y, fn);%0A%7D;%0A%0A
+/**%0A * Reblog a post to%0A * It's almost a alias of Reblogs#add()%0A *%0A * @param %7BNumber%7D dest destination%0A * @param %7BString%7D %5Bnote%5D%0A * @param %7BFunction%7D fn%0A * @api public%0A */%0A%0AReblog.prototype.to = function(dest, note, fn)%7B%0A  if ('function' == typeof note) %7B%0A    fn = note;%0A    note = null;%0A  %7D%0A%0A  this.add(%7B note: note, destination_site_id: dest %7D, fn);%0A%7D;%0A%0A
 /**%0A * Expos

add .to() and .state() methods