diff --git a/README.md b/README.md index 2a22461..6e22d80 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ var Box = require('nodejs-box'); var box = new Box({ access_token: 'YOUR_ACCESS_TOKEN_GOES_HERE', - refreh_token: 'YOUR_REFRESH_TOKEN_GOES_HERE' + refresh_token: 'YOUR_REFRESH_TOKEN_GOES_HERE' }); ``` diff --git a/lib/index.js b/lib/index.js index 2c1fa16..b45d8bd 100644 --- a/lib/index.js +++ b/lib/index.js @@ -458,3 +458,34 @@ Events.prototype.get = function (stream_position, callback) { }); }; +Events.prototype.longPollOptions = function (callback) { + request({ + method: 'options', + uri: this.options.base_url+'/'+this.resource, + headers: { + 'Authorization': this.options.auth + } + }) + .end(function (res) { + if (res.error) { + return callback('Error: '+res.error.message) + } + + callback(null, res.body); + }); +} + +Events.prototype.longPoll = function(url, stream_position, callback) { + var position_url = url+'&stream_position='+stream_position; + + request + .get(position_url) + .set('Authorization', this.options.auth) + .end(function (res) { + if (res.error) { + return callback('Error: '+res.error.message) + } + + callback(null, res.body); + }); +}