request-json
Advanced tools
Comparing version 0.4.8 to 0.4.9
38
main.js
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var fs, parseBody, request, url; | ||
var clone, fs, parseBody, request, url; | ||
@@ -11,2 +11,11 @@ request = require("request"); | ||
clone = function(obj) { | ||
var key, result; | ||
result = {}; | ||
for (key in obj) { | ||
result[key] = obj[key]; | ||
} | ||
return result; | ||
}; | ||
parseBody = function(error, response, body, callback) { | ||
@@ -63,3 +72,3 @@ var err, parsed; | ||
} | ||
options = this.options; | ||
options = clone(this.options); | ||
options.method = 'GET'; | ||
@@ -82,3 +91,3 @@ options.uri = url.resolve(this.host, path); | ||
} | ||
options = this.options; | ||
options = clone(this.options); | ||
options.method = "POST"; | ||
@@ -102,3 +111,3 @@ options.uri = url.resolve(this.host, path); | ||
} | ||
options = this.options; | ||
options = clone(this.options); | ||
options.method = "PUT"; | ||
@@ -117,2 +126,21 @@ options.uri = url.resolve(this.host, path); | ||
JsonClient.prototype.patch = function(path, json, callback, parse) { | ||
var options; | ||
if (parse == null) { | ||
parse = true; | ||
} | ||
options = clone(this.options); | ||
options.method = "PATCH"; | ||
options.uri = url.resolve(this.host, path); | ||
options.json = json; | ||
options.headers = this.headers; | ||
return request(options, function(error, response, body) { | ||
if (parse) { | ||
return parseBody(error, response, body, callback); | ||
} else { | ||
return callback(error, response, body); | ||
} | ||
}); | ||
}; | ||
JsonClient.prototype.del = function(path, callback, parse) { | ||
@@ -123,3 +151,3 @@ var options; | ||
} | ||
options = this.options; | ||
options = clone(this.options); | ||
options.method = "DELETE"; | ||
@@ -126,0 +154,0 @@ options.uri = url.resolve(this.host, path); |
@@ -18,3 +18,3 @@ { | ||
], | ||
"version": "0.4.8", | ||
"version": "0.4.9", | ||
"homepage": "https://github.com/mycozycloud/request-json/", | ||
@@ -30,2 +30,3 @@ "bugs": { | ||
"Frank Rousseau", | ||
"Alan Plum", | ||
"Fábio Santos", | ||
@@ -32,0 +33,0 @@ "Stephen Tweeddale", |
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
11348
185