resource-client
Advanced tools
Comparing version 1.3.1 to 1.3.2
@@ -45,3 +45,3 @@ // Generated by CoffeeScript 1.8.0 | ||
requestUrl = UrlAssembler().template(url).param(paramConfig).query(queryParams).toString(); | ||
return actionRequest({ | ||
return actionRequest.get({ | ||
url: requestUrl | ||
@@ -60,3 +60,3 @@ }, function(err, response) { | ||
requestUrl = UrlAssembler().template(baseUrl).query(queryParams).toString(); | ||
return actionRequest({ | ||
return actionRequest.get({ | ||
url: requestUrl | ||
@@ -69,32 +69,13 @@ }, function(err, response) { | ||
actionUrl = options.method === 'POST' ? baseUrl : url; | ||
Resource[actionName] = function(body, queryParams, done) { | ||
var requestUrl; | ||
if (queryParams == null) { | ||
queryParams = {}; | ||
return (function(methodFn) { | ||
if (methodFn === 'delete') { | ||
methodFn = 'del'; | ||
} | ||
done = arguments[arguments.length - 1]; | ||
requestUrl = (function() { | ||
var idField, _i, _len; | ||
requestUrl = UrlAssembler().template(actionUrl); | ||
for (_i = 0, _len = idFields.length; _i < _len; _i++) { | ||
idField = idFields[_i]; | ||
requestUrl.param(idField, body[idField]); | ||
Resource[actionName] = function(body, queryParams, done) { | ||
var requestUrl; | ||
if (queryParams == null) { | ||
queryParams = {}; | ||
} | ||
return requestUrl.query(queryParams).toString(); | ||
})(); | ||
return actionRequest({ | ||
url: requestUrl, | ||
body: body | ||
}, function(err, response) { | ||
return handleResponse(err, response, null, done); | ||
}); | ||
}; | ||
return Resource.prototype[actionName] = function(queryParams, done) { | ||
var requestUrl; | ||
if (queryParams == null) { | ||
queryParams = {}; | ||
} | ||
done = arguments[arguments.length - 1]; | ||
requestUrl = (function(_this) { | ||
return function() { | ||
done = arguments[arguments.length - 1]; | ||
requestUrl = (function() { | ||
var idField, _i, _len; | ||
@@ -104,14 +85,38 @@ requestUrl = UrlAssembler().template(actionUrl); | ||
idField = idFields[_i]; | ||
requestUrl.param(idField, _this[idField]); | ||
requestUrl.param(idField, body[idField]); | ||
} | ||
return requestUrl.query(queryParams).toString(); | ||
}; | ||
})(this)(); | ||
return actionRequest({ | ||
url: requestUrl, | ||
body: this | ||
}, function(err, response) { | ||
return handleResponse(err, response, this, done); | ||
}); | ||
}; | ||
})(); | ||
return actionRequest[methodFn]({ | ||
url: requestUrl, | ||
body: body | ||
}, function(err, response) { | ||
return handleResponse(err, response, null, done); | ||
}); | ||
}; | ||
return Resource.prototype[actionName] = function(queryParams, done) { | ||
var requestUrl; | ||
if (queryParams == null) { | ||
queryParams = {}; | ||
} | ||
done = arguments[arguments.length - 1]; | ||
requestUrl = (function(_this) { | ||
return function() { | ||
var idField, _i, _len; | ||
requestUrl = UrlAssembler().template(actionUrl); | ||
for (_i = 0, _len = idFields.length; _i < _len; _i++) { | ||
idField = idFields[_i]; | ||
requestUrl.param(idField, _this[idField]); | ||
} | ||
return requestUrl.query(queryParams).toString(); | ||
}; | ||
})(this)(); | ||
return actionRequest[methodFn]({ | ||
url: requestUrl, | ||
body: this | ||
}, function(err, response) { | ||
return handleResponse(err, response, this, done); | ||
}); | ||
}; | ||
})(options.method.toLowerCase()); | ||
} | ||
@@ -118,0 +123,0 @@ }; |
{ | ||
"name": "resource-client", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Easily create api clients for your server side resources.", | ||
@@ -27,4 +27,3 @@ "author": "Good Eggs <open-source@goodeggs.com>", | ||
"lodash": "^3.0.0", | ||
"url-assembler": "0.0.3", | ||
"chai": "^2.1.0" | ||
"url-assembler": "0.0.3" | ||
}, | ||
@@ -34,2 +33,3 @@ "devDependencies": { | ||
"mocha": "~1.x.x", | ||
"chai": "^2.1.0", | ||
"express": "^4.11.1", | ||
@@ -36,0 +36,0 @@ "body-parser": "^1.10.2", |
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
19182
3
174
8
- Removedchai@^2.1.0
- Removedassertion-error@1.0.0(transitive)
- Removedchai@2.3.0(transitive)
- Removeddeep-eql@0.1.3(transitive)
- Removedtype-detect@0.1.1(transitive)