-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWarpExchange.js
More file actions
56 lines (46 loc) · 1.57 KB
/
WarpExchange.js
File metadata and controls
56 lines (46 loc) · 1.57 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
var unirest = require('unirest'),
crypto = require('crypto'),
qs = require('querystring');
let config = {
apiKey: '.....eyuUWirZI5P02pePz.....',
};
var BASE_URL = 'https://api.warpexchange.com';
var WarpExchangeTrade = function () {
this.apiKey = config.apiKey;
}
WarpExchangeTrade.prototype = {
execute: function (method, parameters, res, callback) {
var url_params = JSON.stringify(parameters);
//console.log(url_params);
unirest.post(BASE_URL + method)
.headers('authorizationToken', this.apiKey)
.headers('Content-Type', 'application/json')
.send(url_params)
.end(function (response) {
if (response.raw_body) {
callback(null, JSON.parse(response.raw_body));
}
else {
callback(response);
}
});
}
}
var WarpExchange = {
WarpExchangeTrade: new WarpExchangeTrade(),
getnewaddress: function (params, callback) {
//console.log(params);
this.WarpExchangeTrade.execute('/getnewaddress', params, console.log, callback);
},
gettransactioninformation: function (params, callback) {
//console.log(params);
this.WarpExchangeTrade.execute('/gettransactioninformation', params, console.log, callback);
},
gettransactions: function (callback) {
this.WarpExchangeTrade.execute('/gettransactions', null, console.log, callback);
},
ToBTC: function (value, callback) {
return value / 100000000;
}
};
module.exports = WarpExchange;