forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport.js
More file actions
39 lines (34 loc) · 931 Bytes
/
Copy pathreport.js
File metadata and controls
39 lines (34 loc) · 931 Bytes
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
const x = require('../xendit');
const { Report } = x;
const r = new Report({});
function sleepFor(sleepDuration) {
var now = new Date().getTime();
while (new Date().getTime() < now + sleepDuration) {
/* Do nothing */
}
}
(async function() {
try {
const genReport = await r.generateReport({
type: 'BALANCE_HISTORY',
// yesterday's date
filterDateFrom: new Date(new Date().getTime() - 24 * 60 * 60 * 1000),
filterDateTo: new Date(),
format: 'CSV',
currency: 'IDR',
});
// eslint-disable-next-line no-console
console.log('generate report:', genReport);
sleepFor(3000);
const getReport = await r.getReport({
id: genReport.id,
});
// eslint-disable-next-line no-console
console.log('get report', getReport);
process.exit(0);
} catch (e) {
// eslint-disable-next-line no-console
console.error(e);
process.exit(1);
}
})();