mayar 0.1.0 → 0.1.1

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/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "mayar",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Zero-dependency Node.js CLI for the Mayar API (production endpoint).",
5
5
  "bin": {
6
- "mayar": "./bin/mayar.js"
6
+ "mayar": "bin/mayar.js"
7
7
  },
8
8
  "main": "src/cli.js",
9
9
  "scripts": {
@@ -4,14 +4,22 @@ const { checkResp } = require('../util');
4
4
 
5
5
  const USAGE = 'Usage: mayar tx <list|unpaid>';
6
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
+
7
13
  function renderTx(body) {
8
14
  const data = (body && body.data) || [];
9
15
  const rows = data.map((t) => ({
10
16
  id: t.id,
11
- customer: (t.customer && (t.customer.name || t.customer.email)) || t.customerName || '',
12
- amount: t.amount,
13
- status: t.status,
14
- createdAt: t.createdAt,
17
+ customer: (t.customer && (t.customer.name || t.customer.email))
18
+ || (t.paymentLink && t.paymentLink.name)
19
+ || t.customerName || '',
20
+ amount: t.credit ?? t.amount ?? '',
21
+ status: t.status || '',
22
+ createdAt: fmtDate(t.createdAt),
15
23
  }));
16
24
  ui.table(rows, ['id', 'customer', 'amount', 'status', 'createdAt']);
17
25
  }