(function () {
    'use strict';
 
    angular.module('Monitour.pages.user')
        .factory('UserService', UserService);
 
    function UserService($http, $localStorage) {
	    
		var service = {}; 
		
        service.GetAll = GetAll;
		 service.Me = Me;
		service.GetAllPage = GetAllPage;
        service.GetById = GetById;
		service.Count = Count;
        service.GetByUsername = GetByUsername;
        service.Create = Create;
        service.Update = Update;
        service.Delete = Delete;
		service.userlabels = userlabels;
        service.labels = labels;
 
 
        var domain  = 'https://api.callio.com.au/public/';
        return service;
   
		
        function GetAll() {
            return $http.get(domain + 'users');
        }
		function Me() {
			return $http.get(domain + '/users/me');
		}
				
        function Count() {
            return $http.get(domain + 'users/count');
        }
        	
        function GetAllPage(itemsper, pager) {
            return $http.get(domain + 'users?page=' + pager + '&limit=' + itemsper);
        }
		  		
        function GetById(id) {
            return $http.get(domain + 'users/' + id);
        }
 
        function GetByUsername(username) {
            return $http.get(domain + 'users' + username);
        }
 
        function Create(user) {
            return $http.post(domain + 'usernew', user);
        }
 
        function Update(user, id) {
            return $http.patch(domain + 'userupdate/' + id, user);
        }
		
		function userlabels(id) {
			 return $http.get(domain + 'userlabels');
		}
		
		function labels() {
			
			return $http.get(domain + 'labels');
		}
 
        function Delete(id) {
            return $http.delete(domain + 'users/' + id);
        }
		
    
 
        // private functions
 
 
      
    }
 
})();