-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathSEP6.js
More file actions
84 lines (63 loc) · 2.41 KB
/
SEP6.js
File metadata and controls
84 lines (63 loc) · 2.41 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const fetch = require('node-fetch');
const querystring = require('querystring');
const { loadToken } = require('./TokenStore');
const url = 'https://api.cowrie.exchange/transfer/';
const jwt = loadToken();
module.exports = {
deposit: (asset_code, account, amount, customer_id) => {
var query = querystring.stringify({ asset_code: asset_code, account: account, amount: amount, customer_id: customer_id });
var api = url + 'deposit?' + query;
console.log(api);
var deposit_response =
fetch(api, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${jwt}`
}
}).then((response) => {
console.log('deposit_response: ' + response.status + ' ' + response.statusText);
if (response.status == 200) {
return response.json();
}
else {
throw response.statusText;
}
}).then((body) => {
console.log('deposit_response: ' + JSON.stringify(body));
return body;
}).catch((error) => {
console.log('deposit_error: ' + error);
throw error;
});
return deposit_response;
},
withdraw: (asset_code, account, amount, customer_id, bankCode, bankAccount) => {
var query = querystring.stringify({ asset_code: asset_code, account: account, amount:amount, customer_id: customer_id, dest_extra: bankCode, dest: bankAccount});
var api = url + 'withdraw?' + query;
console.log(api);
var withdraw_response =
fetch(api, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${jwt}`
}
}).then((response) => {
console.log('withdraw_response: ' + response.status + ' ' + response.statusText);
if (response.status == 200) {
return response.json();
}
else {
throw response.statusText;
}
}).then((body) => {
console.log('withdraw_response: ' + JSON.stringify(body));
return body;
}).catch((error) => {
console.log('withdraw_error: ' + error);
throw error;
});
return withdraw_response;
}
}