· 8 years ago · Dec 15, 2017, 01:24 PM
1/**
2 * @header
3 * @name MyCred API call
4 * @description Integrate with MyCred
5 * @category Custom APIs
6 */
7
8/**
9 * @inspectable
10 * @name Transition
11 * @description Where this block transitions when it is finished
12 * @type transition
13 */
14const transition = `57410cd5-9b2c-499a-a3f8-1962ffabffb4`;
15
16
17const secretKey = 'HIDDEN';
18const remoteUrl = 'HIDDEN';
19
20const action = 'CREDIT';
21const account = 'HIDDEN@HIDDEN.edu';
22const amount = 10;
23const ref = 'metaverse';
24//const refId = 0;
25const entry = 'Points for completing a Metaverse Experience!';
26//const data = 'optional extra';
27const pointType = 'mycred_default';
28
29const host = 'https://www.gonmeta.io';
30
31// Calculate token
32
33
34
35let token = `${host}${action}${amount}${secretKey}`;
36token = await Meta.actions.post(`http://api.rest7.com/v1/text_hash.php?text=${token}&algo=md5`, { method: 'get' });
37token = await token.json();
38token = JSON.stringify(token);
39token = token.hash;
40
41Meta.actions.post(remoteUrl, {
42 method: 'POST',
43 headers: {
44 Accept: 'application/x-www-form-urlencoded',
45 'Content-Type': 'application/x-www-form-urlencoded',
46 },
47 //body: `action=${action}&account=${account}&amount=${amount}&ref=${ref}&ref_id=${refId}&type=${pointType}&entry=${entry}&data=${data}&host=${host}&token=${token}`,
48 body: `action=${action}&account=${account}&amount=${amount}&ref=${ref}&type=${pointType}&entry=${entry}&host=${host}&token=${token}`,
49});
50
51Meta.callbacks.transitionTo(transition);