mirror of
https://github.com/Foltik/Shimapan
synced 2024-11-13 00:26:55 -05:00
Create InviteSvc
This commit is contained in:
parent
6b22e0790e
commit
6f707138f6
58
app/public/services/InviteSvc.js
Normal file
58
app/public/services/InviteSvc.js
Normal file
@ -0,0 +1,58 @@
|
||||
var angular = require('angular');
|
||||
|
||||
angular.module('InviteSvc', []).service('InviteService', ['$http', function ($http) {
|
||||
this.getInvite = function (code, cb) {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/api/invites/get',
|
||||
params: {code: code}
|
||||
}).then(function (res) {
|
||||
cb(res.data);
|
||||
});
|
||||
};
|
||||
|
||||
this.getAllInvites = function (cb) {
|
||||
$http({
|
||||
method: 'GET',
|
||||
url: '/api/invites/get'
|
||||
}).then(function (res) {
|
||||
cb(res.data);
|
||||
});
|
||||
};
|
||||
|
||||
this.deleteInvite = function (invite, cb) {
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: '/api/invites/delete',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencode'},
|
||||
transformRequest: function (obj) {
|
||||
var str = [];
|
||||
for (var p in obj)
|
||||
if (obj.hasOwnProperty(p))
|
||||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
||||
return str.join("&");
|
||||
},
|
||||
data: {code: invite.code}
|
||||
}).then(function (res) {
|
||||
cb(res.data);
|
||||
});
|
||||
};
|
||||
|
||||
this.createInvite = function (invite, cb) {
|
||||
$http({
|
||||
method: 'POST',
|
||||
url: '/api/invites/create',
|
||||
headers: {'Content-Type': 'application/x-www-form-urlencode'},
|
||||
transformRequest: function (obj) {
|
||||
var str = [];
|
||||
for (var p in obj)
|
||||
if (obj.hasOwnProperty(p))
|
||||
str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
|
||||
return str.join("&");
|
||||
},
|
||||
data: invite
|
||||
}).then(function(res) {
|
||||
cb(res.data);
|
||||
});
|
||||
};
|
||||
}]);
|
Loading…
Reference in New Issue
Block a user