Semaphore/public/js/factories/credential.js

29 lines
624 B
JavaScript
Raw Normal View History

2014-08-25 12:35:49 +02:00
define(['app'], function (app) {
app.registerFactory('Credential', ['$http', function ($http) {
var Credential = function (id) {
2014-08-25 12:35:49 +02:00
if (!id) {
return;
}
this.id = id;
}
Credential.prototype.save = function () {
2014-08-25 12:35:49 +02:00
return $http.put('/credential/'+this.data._id, this.data);
}
Credential.prototype.add = function () {
2014-08-25 12:35:49 +02:00
return $http.post('/credentials', this.data);
}
Credential.prototype.delete = function () {
2014-08-25 12:35:49 +02:00
return $http.delete('/credential/'+this.data._id);
}
Credential.prototype.get = function () {
2014-08-25 12:35:49 +02:00
return $http.get('/credential/'+this.id);
}
return Credential;
2014-08-25 12:35:49 +02:00
}])
})