mayar 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/package.json +1 -1
- package/src/cli.js +9 -0
- package/src/commands/customer.js +24 -2
- package/src/commands/review.js +42 -0
- package/src/commands/transaction.js +12 -1
package/README.md
CHANGED
|
@@ -93,10 +93,17 @@ Single payment requests
|
|
|
93
93
|
Customers
|
|
94
94
|
customer list [--page ...] GET /hl/v1/customer
|
|
95
95
|
customer create --data <json|@file> POST /hl/v1/customer/create
|
|
96
|
+
customer search <email> GET /hl/v1/customer/detail?email=
|
|
97
|
+
customer update <from> <to> POST /hl/v1/customer/update
|
|
98
|
+
customer magic-link <email> POST /hl/v1/customer/login/portal
|
|
96
99
|
|
|
97
100
|
Transactions
|
|
98
101
|
tx list [--page ...] GET /hl/v1/transactions (paid)
|
|
99
102
|
tx unpaid [--page ...] GET /hl/v1/transactions/unpaid
|
|
103
|
+
tx daily GET /hl/v1/transactions/daily
|
|
104
|
+
|
|
105
|
+
Reviews
|
|
106
|
+
review list [--page ...] GET /hl/v1/reviews
|
|
100
107
|
|
|
101
108
|
Dynamic QR
|
|
102
109
|
qrcode <amount> POST /hl/v1/qrcode/create
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -43,10 +43,17 @@ ${ui.bold('Single payment requests:')}
|
|
|
43
43
|
${ui.bold('Customers:')}
|
|
44
44
|
customer list [--page N --pageSize N]
|
|
45
45
|
customer create --data <json|@file.json>
|
|
46
|
+
customer search <email> Look up a customer by email
|
|
47
|
+
customer update <fromEmail> <toEmail>
|
|
48
|
+
customer magic-link <email> Email a portal login link to the customer
|
|
46
49
|
|
|
47
50
|
${ui.bold('Transactions:')}
|
|
48
51
|
tx list [--page N --pageSize N] Paid transactions
|
|
49
52
|
tx unpaid [--page N --pageSize N] Unpaid transactions
|
|
53
|
+
tx daily Today's totals (volume + count)
|
|
54
|
+
|
|
55
|
+
${ui.bold('Reviews:')}
|
|
56
|
+
review list [--page N --pageSize N]
|
|
50
57
|
|
|
51
58
|
${ui.bold('Dynamic QR:')}
|
|
52
59
|
qrcode <amount>
|
|
@@ -170,6 +177,8 @@ async function run(argv) {
|
|
|
170
177
|
qr: './commands/qrcode',
|
|
171
178
|
qrcode: './commands/qrcode',
|
|
172
179
|
webhook: './commands/webhook',
|
|
180
|
+
review: './commands/review',
|
|
181
|
+
reviews: './commands/review',
|
|
173
182
|
};
|
|
174
183
|
const handler = handlers[cmd];
|
|
175
184
|
if (!handler) {
|
package/src/commands/customer.js
CHANGED
|
@@ -2,10 +2,10 @@ const api = require('../api');
|
|
|
2
2
|
const ui = require('../ui');
|
|
3
3
|
const { checkResp, readData } = require('../util');
|
|
4
4
|
|
|
5
|
-
const USAGE = 'Usage: mayar customer <list|create>';
|
|
5
|
+
const USAGE = 'Usage: mayar customer <list|create|search|update|magic-link>';
|
|
6
6
|
|
|
7
7
|
async function run({ apiKey, flags, positional }) {
|
|
8
|
-
const [sub] = positional;
|
|
8
|
+
const [sub, ...rest] = positional;
|
|
9
9
|
switch (sub) {
|
|
10
10
|
case 'list': {
|
|
11
11
|
const res = await api.request('GET', '/hl/v1/customer', {
|
|
@@ -26,6 +26,28 @@ async function run({ apiKey, flags, positional }) {
|
|
|
26
26
|
const res = await api.request('POST', '/hl/v1/customer/create', { apiKey, body });
|
|
27
27
|
checkResp(res); ui.jsonOut(res.body); return;
|
|
28
28
|
}
|
|
29
|
+
case 'search': {
|
|
30
|
+
if (!rest[0]) throw new Error('Usage: mayar customer search <email>');
|
|
31
|
+
const res = await api.request('GET', '/hl/v1/customer/detail', {
|
|
32
|
+
apiKey, query: { email: rest[0] },
|
|
33
|
+
});
|
|
34
|
+
checkResp(res); ui.jsonOut(res.body); return;
|
|
35
|
+
}
|
|
36
|
+
case 'update': {
|
|
37
|
+
if (rest.length < 2) throw new Error('Usage: mayar customer update <fromEmail> <toEmail>');
|
|
38
|
+
const res = await api.request('POST', '/hl/v1/customer/update', {
|
|
39
|
+
apiKey, body: { fromEmail: rest[0], toEmail: rest[1] },
|
|
40
|
+
});
|
|
41
|
+
checkResp(res); ui.jsonOut(res.body); return;
|
|
42
|
+
}
|
|
43
|
+
case 'magic-link':
|
|
44
|
+
case 'magiclink': {
|
|
45
|
+
if (!rest[0]) throw new Error('Usage: mayar customer magic-link <email>');
|
|
46
|
+
const res = await api.request('POST', '/hl/v1/customer/login/portal', {
|
|
47
|
+
apiKey, body: { email: rest[0] },
|
|
48
|
+
});
|
|
49
|
+
checkResp(res); ui.jsonOut(res.body); return;
|
|
50
|
+
}
|
|
29
51
|
default:
|
|
30
52
|
throw new Error(USAGE);
|
|
31
53
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const api = require('../api');
|
|
2
|
+
const ui = require('../ui');
|
|
3
|
+
const { checkResp } = require('../util');
|
|
4
|
+
|
|
5
|
+
const USAGE = 'Usage: mayar review <list>';
|
|
6
|
+
|
|
7
|
+
function fmtDate(v) {
|
|
8
|
+
if (v == null) return '';
|
|
9
|
+
if (typeof v === 'number') return new Date(v).toISOString();
|
|
10
|
+
return String(v);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async function run({ apiKey, flags, positional }) {
|
|
14
|
+
const [sub] = positional;
|
|
15
|
+
switch (sub) {
|
|
16
|
+
case undefined:
|
|
17
|
+
case 'list': {
|
|
18
|
+
const res = await api.request('GET', '/hl/v1/reviews', {
|
|
19
|
+
apiKey, query: { page: flags.page, pageSize: flags.pageSize },
|
|
20
|
+
});
|
|
21
|
+
checkResp(res);
|
|
22
|
+
if (flags.json) return ui.jsonOut(res.body);
|
|
23
|
+
const data = (res.body && res.body.data) || [];
|
|
24
|
+
const rows = data.map((r) => ({
|
|
25
|
+
id: r.id,
|
|
26
|
+
rating: r.rating,
|
|
27
|
+
customer: (r.customer && (r.customer.name || r.customer.email)) || '',
|
|
28
|
+
message: r.message || '',
|
|
29
|
+
status: r.status || '',
|
|
30
|
+
createdAt: fmtDate(r.createdAt),
|
|
31
|
+
}));
|
|
32
|
+
ui.table(rows, ['id', 'rating', 'customer', 'message', 'status', 'createdAt']);
|
|
33
|
+
const m = res.body || {};
|
|
34
|
+
process.stdout.write(ui.dim(`page ${m.page ?? '?'} / ${m.pageCount ?? '?'} · total ${m.total ?? data.length}`) + '\n');
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
default:
|
|
38
|
+
throw new Error(USAGE);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = { run };
|
|
@@ -2,7 +2,7 @@ const api = require('../api');
|
|
|
2
2
|
const ui = require('../ui');
|
|
3
3
|
const { checkResp } = require('../util');
|
|
4
4
|
|
|
5
|
-
const USAGE = 'Usage: mayar tx <list|unpaid>';
|
|
5
|
+
const USAGE = 'Usage: mayar tx <list|unpaid|daily>';
|
|
6
6
|
|
|
7
7
|
function fmtDate(v) {
|
|
8
8
|
if (v == null) return '';
|
|
@@ -45,6 +45,17 @@ async function run({ apiKey, flags, positional }) {
|
|
|
45
45
|
if (flags.json) return ui.jsonOut(res.body);
|
|
46
46
|
renderTx(res.body); return;
|
|
47
47
|
}
|
|
48
|
+
case 'daily': {
|
|
49
|
+
const res = await api.request('GET', '/hl/v1/transactions/daily', { apiKey });
|
|
50
|
+
checkResp(res);
|
|
51
|
+
if (flags.json) return ui.jsonOut(res.body);
|
|
52
|
+
const d = (res.body && res.body.data) || {};
|
|
53
|
+
if (d.date) process.stdout.write(`${ui.bold('Date:')} ${d.date}\n`);
|
|
54
|
+
if (d.tpvCount != null) process.stdout.write(`${ui.bold('Total volume:')} ${Number(d.tpvCount).toLocaleString('id-ID')}\n`);
|
|
55
|
+
if (d.trxCount != null) process.stdout.write(`${ui.bold('Transactions:')} ${d.trxCount}\n`);
|
|
56
|
+
if (!d.date && !d.tpvCount && !d.trxCount) ui.jsonOut(res.body);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
48
59
|
default:
|
|
49
60
|
throw new Error(USAGE);
|
|
50
61
|
}
|