/**
 * Constructs an accessor for Events that will use the dispatcher
 * for all requests to the API
 * @class
 * @classdesc A wrapper for Events resource
 * @param {Dispatcher} dispatcher The API dispatcher
 */
function Events(dispatcher) {
  /**
   * An instance of the dispatcher. This is usually passed from the client.
   * @type {Dispatcher}
   */
  this.dispatcher = dispatcher;
}

/**
 * Dispatches a GET request to /events of the API to get a set of recent
 * changes to a resource.
 * @param  {Number} resourceId  The id of the resource to get events for
 * @param  {String} [syncToken] Token from a previous sync, if any
 * @return {Promise}            The result of the API call:
 *     {String} sync     The new sync token to use for the next request
 *     {Object[]} [data] The changes on the resource since the last sync,
 *                       may not exist if sync token is new.
 */
Events.prototype.get = function(resourceId, syncToken) {
  var params = { resource: resourceId };
  if (syncToken) {
    params.sync = syncToken;
  }
  return this.dispatcher.get('/events', params, { fullPayload: true});
};

module.exports = Events;
@@ -1,12 +1,127 @@
+var EventEmitter = require('events').EventEmitter;%0Avar util = require('util');%0Avar Promise = require('bluebird');%0A%0A
 /**%0A * Const
@@ -1236,16 +1236,1634 @@
 %7D);%0A%7D;%0A%0A
+%0A/**%0A * Begins polling the /events endpoint of the API to listent to changes%0A * to a resource.%0A * @param  %7BNumber%7D resourceId  The id of the resource to get events for%0A * @param  %7BObject%7D %5Boptions%5D   Additional options to pass the stream.%0A *     %7BNumber%7D periodSeconds%0A *     %7BBoolean%7D continueOnError%0A * @return %7BEventStream%7D      An EventEmitter that emits notifications%0A *                              about changes.%0A */%0AEvents.prototype.stream = function(resourceId, options) %7B%0A  return new EventStream(this, resourceId, options);%0A%7D;%0A%0A%0Afunction EventStream(events, resourceId, options) %7B%0A  this.resourceId = resourceId;%0A  this.events = events;%0A  this.syncToken = null;%0A  this.started = false;%0A  this.options = options %7C%7C %7B%7D;%0A  this.options.periodSeconds = this.options.periodSeconds %7C%7C 5;%0A%7D%0A%0Autil.inherits(EventStream, EventEmitter);%0A%0AEventStream.prototype.start = function() %7B%0A  if (!this.started) %7B%0A    this.started = true;%0A    this._poll();%0A  %7D%0A%7D;%0A%0AEventStream.prototype.stop = function() %7B%0A  this.started = false;%0A%7D;%0A%0AEventStream.prototype._poll = function() %7B%0A  var me = this;%0A%0A  function schedule() %7B%0A    Promise.delay(me.options.periodSeconds * 1000).then(function() %7B%0A      me._poll();%0A    %7D)%0A  %7D%0A%0A  me.events.get(me.resourceId, me.syncToken).then(function(response) %7B%0A    me.syncToken = response.sync_token;%0A    if (response.data) %7B%0A      data.forEach(function(event) %7B%0A        me.emit('event', event);%0A      %7D);%0A    %7D%0A    schedule();%0A  %7D).catch(function(error) %7B%0A    if (me.options.continueOnError) %7B%0A      schedule();%0A    %7D else %7B%0A      me.started = false;%0A    %7D%0A    me.emit('error', error);%0A  %7D);%0A%7D;%0A%0A%0A
 module.e

Add initial EventStream interface