New users.resource

This commit is contained in:
perploug
2013-08-23 12:10:44 +02:00
parent eb60593815
commit c076d21151
6 changed files with 142 additions and 5 deletions

View File

@@ -46,15 +46,15 @@ function entityResource($q, $http, umbRequestHelper) {
/**
* @ngdoc method
* @name umbraco.resources.contentResource#getByIds
* @methodOf umbraco.resources.contentResource
* @name umbraco.resources.entityResource#getByIds
* @methodOf umbraco.resources.entityResource
*
* @description
* Gets an array of content items, given a collection of ids
* Gets an array of entities, given a collection of ids
*
* ##usage
* <pre>
* contentResource.getByIds( [1234,2526,28262])
* entityResource.getByIds( [1234,2526,28262])
* .then(function(contentArray) {
* var myDoc = contentArray;
* alert('they are here!');

View File

@@ -0,0 +1,75 @@
/**
* @ngdoc service
* @name umbraco.resources.userResource
* @description Retrives user data from the server, cannot be used for authentication, for this, use the user.service
*
*
**/
function userResource($q, $http, umbRequestHelper) {
//the factory object returned
return {
/**
* @ngdoc method
* @name umbraco.resources.userResource#getById
* @methodOf umbraco.resources.userResource
*
* @description
* Gets a user with a given id
*
* ##usage
* <pre>
* userResource.getById(1234)
* .then(function(ent) {
* var myUser = ent;
* alert('im here!');
* });
* </pre>
*
* @param {Int} id id of user to return
* @returns {Promise} resourcePromise object containing the user.
*
*/
getById: function (id) {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"userApiBaseUrl",
"GetById",
[{ id: id }])),
'Failed to retreive user data for id ' + id);
},
/**
* @ngdoc method
* @name umbraco.resources.userResource#getAll
* @methodOf umbraco.resources.userResource
*
* @description
* Gets all users available on the system
*
* ##usage
* <pre>
* contentResource.getAll()
* .then(function(userArray) {
* var myUsers = userArray;
* alert('they are here!');
* });
* </pre>
*
* @returns {Promise} resourcePromise object containing the user array.
*
*/
getAll: function () {
return umbRequestHelper.resourcePromise(
$http.get(
umbRequestHelper.getApiUrl(
"userApiBaseUrl",
"GetAll")),
'Failed to retreive all users');
}
};
}
angular.module('umbraco.resources').factory('userResource', userResource);