-
Notifications
You must be signed in to change notification settings - Fork 723
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #427 from marmelab/es6_queries
[RFR] Move *Queries into separate files
- Loading branch information
Showing
39 changed files
with
855 additions
and
941 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*global define*/ | ||
define(function () { | ||
'use strict'; | ||
|
||
function RestWrapper(Restangular) { | ||
this.Restangular = Restangular; | ||
|
||
Restangular.setFullResponse(true); | ||
} | ||
|
||
/** | ||
* Returns the promise of one resource by URL | ||
* | ||
* @param {String} entityName | ||
* @param {String} url | ||
* | ||
* @returns {promise} | ||
*/ | ||
RestWrapper.prototype.getOne = function(entityName, url) { | ||
return this.Restangular | ||
.oneUrl(entityName, url) | ||
.get() | ||
.then(function (response) { | ||
return response.data; | ||
}); | ||
}; | ||
|
||
/** | ||
* Returns the promise of a list of resources | ||
* | ||
* @param {Object} params | ||
* @param {String} entityName | ||
* @param {String} url | ||
* | ||
* @returns {promise} | ||
*/ | ||
RestWrapper.prototype.getList = function(params, entityName, url) { | ||
return this.Restangular | ||
.allUrl(entityName, url) | ||
.getList(params); | ||
}; | ||
|
||
RestWrapper.prototype.createOne = function(rawEntity, entityName, url) { | ||
return this.Restangular | ||
.oneUrl() | ||
.customPOST(rawEntity) | ||
.then(function (response) { | ||
return response.data; | ||
}); | ||
}; | ||
|
||
RestWrapper.prototype.updateOne = function(rawEntity, entityName, url) { | ||
return this.Restangular | ||
.oneUrl(entityName, url) | ||
.customPUT(rawEntity) | ||
.then(function (response) { | ||
return response.data; | ||
}); | ||
}; | ||
|
||
RestWrapper.prototype.deleteOne = function(entityName, url) { | ||
return this.Restangular | ||
.oneUrl(entityName, url) | ||
.customDELETE(); | ||
}; | ||
|
||
RestWrapper.$inject = ['Restangular']; | ||
|
||
return RestWrapper; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.