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