eprolo-cli 1.0.70 → 1.0.72
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/bin/eprolo-cli.js +19 -1
- package/package.json +1 -1
package/bin/eprolo-cli.js
CHANGED
|
@@ -45,6 +45,10 @@ function readFlag(argv, flag) {
|
|
|
45
45
|
// ---------------------------------------------------------------------------
|
|
46
46
|
|
|
47
47
|
function postJson(url, body, headers = {},method = "POST") {
|
|
48
|
+
if(method == "GET") {
|
|
49
|
+
url += "?" + new URLSearchParams(body).toString();
|
|
50
|
+
body = {};
|
|
51
|
+
}
|
|
48
52
|
return new Promise((resolve, reject) => {
|
|
49
53
|
const target = new URL(url);
|
|
50
54
|
const payload = JSON.stringify(body);
|
|
@@ -198,7 +202,17 @@ async function queryOrders(orderId) {
|
|
|
198
202
|
console.error(JSON.stringify({ success: false, errorMessage: "缺少订单 ID" }));
|
|
199
203
|
process.exit(1);
|
|
200
204
|
}
|
|
201
|
-
const data = await postJsonWithRetry(ORDERS_API, {
|
|
205
|
+
const data = await postJsonWithRetry(ORDERS_API, {timestamp:config.timestamp,sign:config.accessToken}, config, "GET");
|
|
206
|
+
console.log(JSON.stringify(data, null, 2));
|
|
207
|
+
process.exit(0);
|
|
208
|
+
}
|
|
209
|
+
async function queryOrderList() {
|
|
210
|
+
const config = readConfig();
|
|
211
|
+
if (!config.accessToken) {
|
|
212
|
+
console.error(JSON.stringify({ success: false, errorMessage: "未授权,请先登录" }));
|
|
213
|
+
process.exit(1);
|
|
214
|
+
}
|
|
215
|
+
const data = await postJsonWithRetry(ORDERS_API, {timestamp:config.timestamp,sign:config.accessToken}, config, "GET");
|
|
202
216
|
console.log(JSON.stringify(data, null, 2));
|
|
203
217
|
process.exit(0);
|
|
204
218
|
}
|
|
@@ -265,6 +279,10 @@ async function main() {
|
|
|
265
279
|
await queryOrders(argv[2]);
|
|
266
280
|
return;
|
|
267
281
|
}
|
|
282
|
+
if (argv[0] === "list") {
|
|
283
|
+
await queryOrderList();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
268
286
|
|
|
269
287
|
printHelp();
|
|
270
288
|
}
|
package/package.json
CHANGED