From fb24d89efd96fd38583126f71a4056c22339a5c3 Mon Sep 17 00:00:00 2001 From: John Cant Date: Thu, 10 Dec 2015 10:02:39 +0000 Subject: [PATCH 1/2] Fix typo in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' }); ``` From 0ed4cc34220da54a3937119ebda97c4f02143372 Mon Sep 17 00:00:00 2001 From: John Cant Date: Mon, 21 Dec 2015 12:46:50 +0000 Subject: [PATCH 2/2] Add events endpoints for long polling --- lib/index.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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); + }); +}