-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.js
More file actions
159 lines (131 loc) · 4.24 KB
/
api.js
File metadata and controls
159 lines (131 loc) · 4.24 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
const qs = require('qs');
const Config = require('./config');
const Signature = require('./signature');
const fetch = require('node-fetch');
module.exports = function(app) {
//Crear una orden básica
app.post('/api/order/create', (req, res) => {
const { usd, coin, tipo, monetizar, enviarCorreo } = req.body;
const body = Signature({ usd, coin, tipo, monetizar, enviarCorreo });
console.log(body);
const url = Config.URL + '/api/receive/order/create';
fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json',
},
json: true
})
.then(res => res.json())
.then(text => {
console.log(text)
res.send(text);
});
});
//Crear una orden completa
app.post('/api/order/create/full', (req, res) => {
const { usd, coin, tipo, monetizar, descripcion, tipo_fee_monetizar, correo, enviarCorreo } = req.body;
const body = Signature({ usd, coin, tipo, monetizar, descripcion, tipo_fee_monetizar, correo, enviarCorreo });
console.log(body);
const url = Config.URL + '/api/v1/receive/order/create';
fetch(url, {
method: 'POST',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json'
},
json: true
})
.then(res => res.json())
.then(text => {
console.log(text)
res.send(text);
});
});
//Cancelar una orden
app.delete('/api/order/cancel', (req, res) => {
const { id } = req.body;
const body = Signature({ id });
const url = Config.URL + '/api/v1/receive/order/cancel';
console.log(body);
fetch(url, {
method: 'DELETE',
body: JSON.stringify(body),
headers: {
'Content-Type': 'application/json'
}
})
.then(res => res.json())
.then(text => {
console.log(text);
res.send(text);
});
});
//Obtener informacion de una orden del un usuario
app.get('/api/order/get', (req, res) => {
const body = Signature(req.query);
const url = Config.URL + '/api/v1/receive/order/get?' + qs.stringify(body);
fetch(url, {
})
.then(res => res.json())
.then(text => {
console.log(text)
res.send(text);
});
});
//Obtener ordenes por estado de un usuario
app.get('/api/order/status', (req, res) => {
const body = Signature(req.query);
const url = Config.URL + '/api/v1/receive/order/status?' + qs.stringify(body);
fetch(url, {
})
.then(res => res.json())
.then(text => {
console.log(text)
res.send(text);
});
});
//Obtener las ordenes publicas para
app.get('/api/order/public', (req, res) => {
const body = Signature(req.query);
const url = Config.URL + '/api/v1/receive/order/public?' + qs.stringify(body);
fetch(url, {
})
.then(res => res.json())
.then(text => {
console.log(text)
res.send(text);
});
});
//Pagar una orden
app.put('/api/order/pay', (req, res) => {
const { coin, codeBitexpay, amount } = req.body;
const body = Signature({ codeBitexpay, coin, amount });
const url = Config.URL + '/api/v1/receive/order/pay';
console.log(body);
fetch(url, {
headers: {
'Content-Type': 'application/json'
},
method: 'PUT',
body: JSON.stringify(body)
})
.then(res => res.json())
.then(text => {
console.log(text);
res.send(text);
});
});
app.get('/api/my/balance',(req, res) => {
const body = Signature(req.query);
const url = Config.URL + '/api/v1/receive/my/balance?' + qs.stringify(body);
fetch(url, {
})
.then(res => res.json())
.then(text => {
console.log(text)
res.send(text);
});
});
}