Created
September 28, 2015 20:32
-
-
Save byronferguson/8e4a43d9d5b100fc96b4 to your computer and use it in GitHub Desktop.
factory to generate RESTful API interface for DI into controllers
This file contains hidden or 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
angular.module('cc.services').factory('studentFactory', function($http) { | |
var urlBase = '/api/v1/index.cfm/students'; | |
var resourceFactory = {}; | |
resourceFactory.getList = function() { | |
return $http.get(urlBase); | |
}; | |
resourceFactory.getStudentByID = function(studentID) { | |
return $http.get(urlBase + '/' + studentID); | |
}; | |
resourceFactory.getStudentByEmail = function(studentEmail) { | |
return $http.get(urlBase + '/' + studentEmail); | |
}; | |
resourceFactory.getReport = function(studentID) { | |
return $http.get(urlBase + '/' + studentID + '/report'); | |
}; | |
resourceFactory.getDetails = function(studentID) { | |
return $http.get(urlBase + '/' + studentID + '/details'); | |
}; | |
resourceFactory.getClusterRanks = function(studentID) { | |
return $http.get(urlBase + '/' + studentID + '/clusterRanks'); | |
}; | |
resourceFactory.createStudent = function(firstName, lastName, email) { | |
return $http.post(urlBase, {firstName: firstName, lastName: lastName, email: email}); | |
} | |
return resourceFactory; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment