lib/wordpress-client.js
function Client(settings, callback) {
  this.debug('new Client', settings.url);
  var self = this;

  // Mixing settings and emitter into instance.
  require('object-emitter').mixin(this);
  require('object-settings').mixin(this);

  // Set defaults and instance settings.
  this.set(Client.defaults).set(settings);

  // Set properties from parsed URL.
  this.set('hostname', this.common.parseURL(this.get('url')).hostname);
  this.set('auth', this.common.parseURL(this.get('url')).auth);
  this.set('blog', this.get('blog') || this.get('blogId'));

  // Instance Properties.
  Object.defineProperties(this, {
    __client: {
      value: this.common.createClient({
        url: settings.url,
        username: settings.username,
        password: settings.password,
        blogId: self.get('blog')
      }),
      enumerable: false,
      configurable: true,
      writable: false
    },
    __queue: {
      value: [],
      enumerable: false,
      configurable: true,
      writable: false
    }
  });

  this.detectBlog(function (err, blog, response) {
    if (err) {
      return self.onceReady.call(self, err);
    }

    self.set('blogs', response);

    // Schedule initial RPC call to verify target is valid.
    self.listMethods(self.onceReady.bind(self));

    // Schedule callback, if provided.
    if (_.isFunction(callback)) {
      self.once('connected', callback);
    }

    // Emit ready event on next tick.
    self.nextTick(self.emit, 'ready', null, self);
  });

  // @chainable
  return this;
}
function Client(settings, callback) {
  this.debug('new Client', settings.url);
  var self = this;

  // Mixing settings and emitter into instance.
  require('object-emitter').mixin(this);
  require('object-settings').mixin(this);

  // Set defaults and instance settings.
  this.set(Client.defaults).set(settings);

  // Set properties from parsed URL.
  this.set('hostname', this.common.parseURL(this.get('url')).hostname);
  this.set('auth', this.common.parseURL(this.get('url')).auth);
  this.set('blog', this.get('blog') || this.get('blogId'));

  // Instance Properties.
  Object.defineProperties(this, {
    __client: {
      value: this.common.createClient({
        url: settings.url,
        username: settings.username,
        password: settings.password,
        blogId: self.get('blog')
      }),
      enumerable: false,
      configurable: true,
      writable: false
    },
    __queue: {
      value: [],
      enumerable: false,
      configurable: true,
      writable: false
    }
  });

  this.detectBlog(function (err, blog, response) {
    if (err) {
      return self.onceReady.call(self, err);
    }

    self.set('blogs', response);

    // Schedule initial RPC call to verify target is valid.
    self.listMethods(self.onceReady.bind(self));

    // Schedule callback, if provided.
    if (_.isFunction(callback)) {
      self.once('connected', callback);
    }

    // Emit ready event on next tick.
    self.nextTick(self.emit, 'ready', null, self);
  });

  // @chainable
  return this;
}
function Client ( settings , callback ) { this . debug ( 'new Client' , settings . url ) ; var self = this ; // Mixing settings and emitter into instance. require ( 'object-emitter' ) . mixin ( this ) ; require ( 'object-settings' ) . mixin ( this ) ; // Set defaults and instance settings. this . set ( Client . defaults ) . set ( settings ) ; // Set properties from parsed URL. this . set ( 'hostname' , this . common . parseURL ( this . get ( 'url' ) ) . hostname ) ; this . set ( 'auth' , this . common . parseURL ( this . get ( 'url' ) ) . auth ) ; this . set ( 'blog' , this . get ( 'blog' ) || this . get ( 'blogId' ) ) ; // Instance Properties. Object . defineProperties ( this , { __client : { value : this . common . createClient ( { url : settings . url , username : settings . username , password : settings . password , blogId : self . get ( 'blog' ) } ) , enumerable : false , configurable : true , writable : false } , __queue : { value : [ ] , enumerable : false , configurable : true , writable : false } } ) ; this . detectBlog ( function ( err , blog , response ) { if ( err ) { return self . onceReady . call ( self , err ) ; } self . set ( 'blogs' , response ) ; // Schedule initial RPC call to verify target is valid. self . listMethods ( self . onceReady . bind ( self ) ) ; // Schedule callback, if provided. if ( _ . isFunction ( callback ) ) { self . once ( 'connected' , callback ) ; } // Emit ready event on next tick. self . nextTick ( self . emit , 'ready' , null , self ) ; } ) ; // @chainable return this ; }
WordPress Client.

@todo Add support for 30X redirect.

### Events
* ready          - Once client instance created.
* connected      - Once client instance created and list of supported methods is returned.
* authenticated  - Once client instance created and list of supported methods is returned.
* error          - Emitted on any response error.

### Settings
* url            - URL to XML-RPC endpoint.
* username       - Username to use.
* password       - Password to use.
* blog           - ID of blog
* key            - As an alternative to usrname and password, if WordPress site supports it.
* methods        - Set with supported RPC methods once client connection is created.
* forceBlog      - when true blog detection function will not replace blogId if it doesn't equal to found one

@param settings
@param callback
@returns {Client}
@constructor
WordPress Client .