buffer-js
Advanced tools
Comparing version 0.0.2 to 0.0.3
'use strict'; | ||
var request = require('request'), | ||
qs = require('querystring'); | ||
var request = require('request'); | ||
var qs = require('querystring'); | ||
var BASE_URL = 'https://api.bufferapp.com/1/'; | ||
@@ -14,4 +14,6 @@ | ||
Base.prototype._http = function(endpoint, method, params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Base.prototype._http = function (endpoint, method, params, callback) { | ||
var opts = { | ||
@@ -22,7 +24,7 @@ url: BASE_URL + endpoint + '?' + qs.stringify(params), | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded' | ||
'Content-Type': 'application/x-www-form-urlencoded', | ||
}, | ||
auth: { | ||
'bearer': this.opts.access_token | ||
} | ||
bearer: this.opts.access_token, | ||
}, | ||
}; | ||
@@ -29,0 +31,0 @@ |
@@ -9,3 +9,3 @@ 'use strict'; | ||
} | ||
this.opts = opts; | ||
@@ -16,6 +16,3 @@ } | ||
Info.prototype.get = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Info.prototype.get = function(callback) { | ||
this._http('/info/configuration.json', 'GET', null, callback); | ||
@@ -22,0 +19,0 @@ }; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
} | ||
this.opts = opts; | ||
@@ -16,6 +16,3 @@ } | ||
Links.prototype.get = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Links.prototype.get = function(params, callback) { | ||
this._http('/links/shares.json', 'GET', params, callback); | ||
@@ -22,0 +19,0 @@ }; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
} | ||
this.opts = opts; | ||
@@ -16,59 +16,34 @@ } | ||
Profiles.prototype.all = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.all = function(callback) { | ||
this._http('profiles.json', 'GET', null, callback); | ||
}; | ||
Profiles.prototype.get = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.get = function(callback) { | ||
this._http('profiles/' + this.opts.profile_id + '.json', 'GET', null, callback); | ||
}; | ||
Profiles.prototype.schedules = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.schedules = function(callback) { | ||
this._http('profiles/' + this.opts.profile_id + '/schedules.json', 'GET', null, callback); | ||
}; | ||
Profiles.prototype.updateSchedules = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.updateSchedules = function(params, callback) { | ||
this._http('profiles/' + this.opts.profile_id + '/schedules/update.json', 'POST', params, callback); | ||
}; | ||
Profiles.prototype.pendingUpdates = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.pendingUpdates = function(params, callback) { | ||
this._http('profiles/' + this.opts.profile_id + '/updates/pending.json', 'GET', params, callback); | ||
}; | ||
Profiles.prototype.sentUpdates = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.sentUpdates = function(params, callback) { | ||
this._http('profiles/' + this.opts.profile_id + '/updates/sent.json', 'GET', params, callback); | ||
}; | ||
Profiles.prototype.reorderUpdates = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.reorderUpdates = function(params, callback) { | ||
this._http('profiles/' + this.opts.profile_id + '/updates/reorder.json', 'POST', params, callback); | ||
}; | ||
Profiles.prototype.shuffleUpdates = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Profiles.prototype.shuffleUpdates = function(params, callback) { | ||
this._http('profiles/' + this.opts.profile_id + '/updates/reorder.json', 'POST', params, callback); | ||
}; | ||
module.exports = Profiles; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
} | ||
this.opts = opts; | ||
@@ -16,52 +16,30 @@ } | ||
Updates.prototype.create = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.create = function(params, callback) { | ||
this._http('updates/create.json', 'POST', params, callback); | ||
}; | ||
Updates.prototype.get = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.get = function(callback) { | ||
this._http('updates/' + this.opts.update_id + '.json', 'GET', null, callback); | ||
}; | ||
Updates.prototype.interactions = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.interactions = function(params, callback) { | ||
this._http('updates/' + this.opts.update_id + '/interactions.json', 'GET', params, callback); | ||
}; | ||
Updates.prototype.update = function (params, callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.update = function(params, callback) { | ||
this._http('updates/' + this.opts.update_id + '/update.json', 'POST', params, callback); | ||
}; | ||
Updates.prototype.share = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.share = function(callback) { | ||
this._http('updates/' + this.opts.update_id + '/share.json', 'POST', null, callback); | ||
}; | ||
Updates.prototype.destroy = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.destroy = function(callback) { | ||
this._http('updates/' + this.opts.update_id + '/destroy.json', 'POST', null, callback); | ||
}; | ||
Updates.prototype.moveTop = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
Updates.prototype.moveTop = function(callback) { | ||
this._http('updates/' + this.opts.update_id + '/move_to_top.json', 'POST', null, callback); | ||
}; | ||
module.exports = Updates; |
@@ -9,3 +9,3 @@ 'use strict'; | ||
} | ||
this.opts = opts; | ||
@@ -16,6 +16,3 @@ } | ||
User.prototype.get = function (callback) { | ||
if (!callback || !(callback instanceof Function)) | ||
throw new Error('Please provide a valid callback function.'); | ||
User.prototype.get = function(callback) { | ||
this._http('user.json', 'GET', null, callback); | ||
@@ -22,0 +19,0 @@ }; |
{ | ||
"name": "buffer-js", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"author": "Eslam A. Hefnawy", | ||
@@ -5,0 +5,0 @@ "bugs": "https://github.com/eahefnawy/buffer-node/issues", |
@@ -26,3 +26,3 @@ Node.js Wrapper for the Buffer API | ||
// Check Buffer API docs to pass the right parameters | ||
// Check the Buffer API docs to pass the right parameters | ||
// based on the method you're calling | ||
@@ -29,0 +29,0 @@ var params = { |
8374
159