Bladeren bron

Create InviteSvc

pull/11/head
Jack Foltz 6 jaren geleden
bovenliggende
commit
6f707138f6
Getekend door: foltik <jack@foltz.io> GPG sleutel-ID: 303F88F996E95541
1 gewijzigde bestanden met toevoegingen van 58 en 0 verwijderingen
  1. +58
    -0
      app/public/services/InviteSvc.js

+ 58
- 0
app/public/services/InviteSvc.js Bestand weergeven

@@ -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);
});
};
}]);

Laden…
Annuleren
Opslaan