pastebin-js
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -29,6 +29,7 @@ 'use strict'; | ||
* Get a paste | ||
* @param {String} id Id of the paste | ||
* @return {Object} Promise | ||
* @param {String} id Id of the paste | ||
* @param {Boolean} isPrivate Is this a private paste? Optional | ||
* @return {Object} Promise | ||
*/ | ||
Pastebin.prototype.getPaste = function (id) { | ||
Pastebin.prototype.getPaste = function (id, isPrivate) { | ||
if (!id) { | ||
@@ -39,3 +40,29 @@ var deferred = Q.defer(); | ||
} | ||
return this._getApi(conf.net.protocol + conf.net.base + conf.net.endpoint.raw + id, null); | ||
if (isPrivate) { | ||
var p = { | ||
api_option : 'show_paste', | ||
api_dev_key : this.config.api_dev_key, | ||
api_paste_key : id, | ||
}; | ||
var deferred = Q.defer(); | ||
if (this.config.api_user_key) { | ||
p.api_user_key = this.config.api_user_key; | ||
} else if (this.config.api_user_name !== null && this.config.api_user_password !== null) { | ||
this | ||
.createAPIuserKey() | ||
.then(function () { | ||
this.getPaste(id, isPrivate) | ||
.then(deferred.resolve) | ||
.catch(deferred.reject); | ||
return deferred.promise; | ||
}.bind(this)) | ||
.catch(deferred.reject); | ||
return deferred.promise; | ||
} else { | ||
deferred.reject(new Error('Error! For private pastes you need to be logged in! Provide username and password!')); | ||
return deferred.promise; | ||
} | ||
return this._postApi(conf.net.protocol + conf.net.base + conf.net.endpoint.apiraw, p); | ||
} | ||
return this._getApi(conf.net.protocol + conf.net.base + conf.net.endpoint.api + id, null); | ||
}; | ||
@@ -42,0 +69,0 @@ |
@@ -21,2 +21,3 @@ 'use strict'; | ||
'post' : 'api/api_post.php', | ||
'apiraw' : 'api/api_raw.php', | ||
'login' : 'api/api_login.php', | ||
@@ -23,0 +24,0 @@ 'raw' : 'raw.php?i=' |
{ | ||
"name": "pastebin-js", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "NodeJS module for Pastebin API", | ||
@@ -5,0 +5,0 @@ "main": "index", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105342
900