-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlayerLoopAPI.js
More file actions
45 lines (41 loc) · 1.14 KB
/
PlayerLoopAPI.js
File metadata and controls
45 lines (41 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const postURL = 'https://api.playerloop.io/reports';
let APIKey = '';
function init(key) {
APIKey = key;
}
// the basic data of players
// you can feed this into createReport()
class playerData {
constructor (id,email = '',handle = '',fullname = '') {
this.id = id
this.email = email
this.handle = handle
this.fullname = fullname
}
toDictionary() {
var data = {
'id':this.id,
'email':this.email,
'handle':this.handle,
'full_name':this.fullname,
}
return data;
};
};
function createReport(content,reportType,player) {
let request = new XMLHttpRequest();
request.open("POST", postURL);
let data = {
'text':content,
'type':reportType,
"accepted_privacy": true,
"client":"javascript",
'player':player.toDictionary()
};
request.setRequestHeader('Content-Type','application/json');
request.setRequestHeader('Authorization',' Bearer ' + APIKey);
request.send(JSON.stringify(data));
}
function openPrivacyPolicy() {
window.open('https://playerloop.io/privacy-policy');
}