diff --git a/lib/index.js b/lib/index.js index f7e0665..c651aa9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -47,10 +47,11 @@ Pandorabot.prototype._buildEndpoint = function(api, glob, file) { return endpoint; }; -Pandorabot.prototype._makeRequestOptions = function(method, api, glob, params, filetype, filename) { +Pandorabot.prototype._makeRequestOptions = function(method, api, glob, params, filetype, filename, proxy) { var requestOptions = { url: this._buildEndpoint(api, glob, filetype, filename), method: method, + proxy: proxy, }; if (method === 'GET' || method === 'PUT' || method === 'DELETE') { @@ -107,36 +108,36 @@ Pandorabot.prototype._request = function(options, filestream, cb) { } }; -Pandorabot.prototype.list = function(cb) { - var options = this._makeRequestOptions('GET', '/bot', true); +Pandorabot.prototype.list = function(cb, proxy) { + var options = this._makeRequestOptions('GET', '/bot', true, null, null, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.create = function(cb) { - var options = this._makeRequestOptions('PUT', '/bot', false); +Pandorabot.prototype.create = function(cb, proxy) { + var options = this._makeRequestOptions('PUT', '/bot', false, null, null, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.delete = function(cb) { - var options = this._makeRequestOptions('DELETE', '/bot', false); +Pandorabot.prototype.delete = function(cb, proxy) { + var options = this._makeRequestOptions('DELETE', '/bot', false, null, null, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.get = function(zip, cb) { +Pandorabot.prototype.get = function(zip, cb, proxy) { var params = {}, options; if (!cb && typeof zip === 'function') cb = zip; if (zip && typeof zip === 'boolean') params.return = 'zip'; - options = this._makeRequestOptions('GET', '/bot', false, params); + options = this._makeRequestOptions('GET', '/bot', false, params, null, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.upload = function(filepath, cb) { +Pandorabot.prototype.upload = function(filepath, cb, proxy) { var self = this; var filename; var file = path.parse(filepath).base; - var options = self._makeRequestOptions('PUT', '/bot', false, null, file); + var options = self._makeRequestOptions('PUT', '/bot', false, null, file, null, proxy); fs.stat(filepath, function(err, stat) { if (err) { @@ -150,29 +151,29 @@ Pandorabot.prototype.upload = function(filepath, cb) { }); }; -Pandorabot.prototype.remove = function(file, cb) { - var options = this._makeRequestOptions('DELETE', '/bot', false, null, file); +Pandorabot.prototype.remove = function(file, cb, proxy) { + var options = this._makeRequestOptions('DELETE', '/bot', false, null, file, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.getFile = function(file, cb) { - var options = this._makeRequestOptions('GET', '/bot', false, null, file) +Pandorabot.prototype.getFile = function(file, cb, proxy) { + var options = this._makeRequestOptions('GET', '/bot', false, null, file, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.compile = function(cb) { - var options = this._makeRequestOptions('GET', '/bot', false); +Pandorabot.prototype.compile = function(cb, proxy) { + var options = this._makeRequestOptions('GET', '/bot', false, null, null, null, proxy); options.url = options.url + '/verify'; this._request(options, cb); }; -Pandorabot.prototype.talk = function(params, cb) { - var options = this._makeRequestOptions('POST', '/talk', false, params); +Pandorabot.prototype.talk = function(params, cb, proxy) { + var options = this._makeRequestOptions('POST', '/talk', false, params, null, null, proxy); this._request(options, cb); }; -Pandorabot.prototype.atalk = function(params, cb) { - var options = this._makeRequestOptions('POST', '/atalk', false, params); +Pandorabot.prototype.atalk = function(params, cb, proxy) { + var options = this._makeRequestOptions('POST', '/atalk', false, params, null, null, proxy); this._request(options, cb); };