Created
November 9, 2016 11:16
-
-
Save mfalade/d887d40401d06a8bddcb1c8be0386e2f to your computer and use it in GitHub Desktop.
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
angular.module('cerqma.services') | |
.factory('Equipments', ['$http', '$rootScope', '$state', | |
'API_PREFIX', | |
function ($http, $rootScope, $q, $state, API_PREFIX) { | |
// Response Handler | |
function returnResponse(res) { | |
return res.data; | |
} | |
function all(filter) { | |
var queryParams = '?'; | |
if (filter && filter.inspector_id) { | |
queryParams = queryParams + '&inspector_id=' + filter.inspector_id; | |
} | |
return $http | |
.get(API_PREFIX + '/equipments' + queryParams) | |
.then(returnResponse); | |
} | |
function findOne(equipmentId) { | |
return $http | |
.get(API_PREFIX + '/equipments/' + equipmentId) | |
.then(returnResponse); | |
} | |
function create(payload) { | |
return $http | |
.post(API_PREFIX + '/equipments', payload) | |
.then(returnResponse); | |
} | |
function update(payload) { | |
return $http | |
.put(API_PREFIX + '/equipments', payload) | |
.then(returnResponse); | |
} | |
function destroy(equipmentId) { | |
return $http | |
.delete(API_PREFIX + '/equipments/' + equipmentId) | |
.then(returnResponse); | |
} | |
return { | |
all: all, | |
findOne: findOne, | |
create: create, | |
update: update, | |
destroy: destroy | |
}; | |
} | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment