Skip to content

Commit 717b7aa

Browse files
authored
Merge pull request #2 from tenfold/tf-3839
TF-3839: Extend Tenfold nforce library to POST a REST API resource by its url
2 parents aa39fc3 + fb04c2e commit 717b7aa

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,14 @@ Connection.prototype.search = function(data, callback) {
721721
return resolver.promise;
722722
};
723723

724+
function requireForwardSlash(uri) {
725+
if (!uri) return '/';
726+
if (uri.charAt(0) !== '/') {
727+
return '/' + uri;
728+
}
729+
return uri;
730+
}
731+
724732
Connection.prototype.getUrl = function(data, callback) {
725733
var opts = this._getOpts(data, callback, {
726734
singleProp: 'url'
@@ -730,6 +738,16 @@ Connection.prototype.getUrl = function(data, callback) {
730738
return this._apiRequest(opts, opts.callback);
731739
};
732740

741+
Connection.prototype.postUrl = function (data, callback) {
742+
var opts = this._getOpts(data, callback, {
743+
singleProp: 'url'
744+
});
745+
opts.uri = opts.oauth.instance_url + requireForwardSlash(opts.url);
746+
opts.method = 'POST';
747+
if(opts.body) opts.body = JSON.stringify(opts.body);
748+
return this._apiRequest(opts, opts.callback);
749+
};
750+
733751
/*****************************
734752
* apex rest
735753
*****************************/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Kevin O'Hara <kevnohara80@gmail.com> (http://kevinmohara.com)",
33
"name": "nforce",
44
"description": "nforce is a REST API wrapper for force.com, database.com, and salesforce.com",
5-
"version": "1.6.0",
5+
"version": "1.6.1",
66
"keywords": [
77
"salesforce",
88
"salesforce.com",

0 commit comments

Comments
 (0)