se-hub/templates/js/services/apiService.js

93 lines
2.3 KiB
JavaScript
Raw Normal View History

2015-06-09 17:16:29 +00:00
var DEBUG = true;
2015-05-09 19:00:14 +00:00
var service = angular.module('seHub.services', []);
service.factory('apiService', ['$http', function($http) {
return {
getUserByToken: function(token){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/getUserByToken/" + token;
2015-05-09 19:00:14 +00:00
req = {
method : "GET",
url : url
};
return $http(req);
},
getAllCampuses: function(token){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/campuses/getAll/" + token;
req = {
method : "GET",
url : url
2015-05-09 19:00:14 +00:00
};
return $http(req);
},
sendValidationMail: function(token, email){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/validation/sendmail/" + token;
payload = {
email: email
};
req = {
method: "POST",
url: url,
data: payload
};
2015-06-16 20:29:34 +00:00
return $http(req);
},
updateUser: function(token, payLoad){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/users/updateUser/" + token;
req = {
method: "POST",
url: url,
data: payLoad
};
2015-05-09 19:00:14 +00:00
return $http(req);
},
getCourseByCampusName: function(token){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
req = {
method : "GET",
2015-06-24 10:13:58 +00:00
url : url
};
return $http(req);
},
getAllCourses: function(token){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAll/" + token;
req = {
method : "GET",
url : url
};
return $http(req);
},
getAllMessages: function(token){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getAllMessages/" + token;
req = {
method : "GET",
url : url
};
return $http(req);
},
2015-06-24 10:13:58 +00:00
createMessage: function(token, payLoad){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseMessages/" + token;
req = {
method : "POST",
url : url,
data: payLoad
};
return $http(req);
},
getCourseMessages: function(token, courseName){
var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/courses/getCourseMessages/" + token + '/' + courseName;
req = {
method : "GET",
url : url
};
return $http(req);
2015-05-09 19:00:14 +00:00
}
};
}]);