eprolo-cli 1.0.102 → 1.0.104

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.
Files changed (2) hide show
  1. package/bin/eprolo-cli.js +29 -4
  2. package/package.json +1 -1
package/bin/eprolo-cli.js CHANGED
@@ -54,10 +54,10 @@ function postJson(url, body, headers = {},method = "POST") {
54
54
  signValue.timestamp = config.timestamp;
55
55
  signValue.sign = config.accessToken;
56
56
  }
57
- url += "?" + new URLSearchParams(signValue).toString();
58
- if(method == "GET") {
59
- body = {};
57
+ if(method == "GET") {
58
+ signValue = {...signValue, ...body};
60
59
  }
60
+ url += "?" + new URLSearchParams(signValue).toString();
61
61
  return new Promise((resolve, reject) => {
62
62
  const target = new URL(url);
63
63
  const payload = JSON.stringify(body);
@@ -282,7 +282,32 @@ async function insertProduct(arg) {
282
282
  }
283
283
  async function addOrder(arg) {
284
284
  const config = readConfig();
285
- const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, JSON.parse(arg), config, "POST");
285
+ const order = JSON.parse(arg);
286
+ const newOrder={};
287
+ const orderItemlist=[];
288
+ newOrder.note=order.name;
289
+ newOrder.shipping_country_code=order.currencyCode;
290
+ newOrder.order_id=getId(order.id);
291
+ if(order.shippingAddress){
292
+ newOrder.shipping_name=order.shippingAddress.firstName + ' ' + order.shippingAddress.lastName;
293
+ newOrder.shipping_phone=order.shippingAddress.phone
294
+ // newOrder.shipping_company=order.
295
+ newOrder.shipping_country=order.shippingAddress.country;
296
+ newOrder.shipping_address=order.shippingAddress.address1;
297
+ newOrder.shipping_province=order.shippingAddress.province;
298
+ // newOrder.shipping_province_code=order.shippingAddress.;
299
+ newOrder.shipping_address2=order.shippingAddress.address2
300
+ newOrder.shipping_city=order.shippingAddress.city;
301
+ // newOrder.shipping_taxNumber=order.shippingAddress.taxNumber;
302
+ }
303
+ order.lineItems.edges.forEach((edge)=>{
304
+ orderItemlist.push({
305
+ variantsid:getId(edge.variant.id),
306
+ quantity:edge.quantity,
307
+ })
308
+ })
309
+ newOrder.orderItemlist=orderItemlist;
310
+ const data = await postJsonWithRetry(`http://43.153.35.208:3000/addInfo`, newOrder, config, "POST");
286
311
  console.log(JSON.stringify(data, null, 2));
287
312
  process.exit(0);
288
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eprolo-cli",
3
- "version": "1.0.102",
3
+ "version": "1.0.104",
4
4
  "description": "CLI for Dianxiaobao ICBU AI publishing, authorization profile management, task submission, and task status checks.",
5
5
  "bin": {
6
6
  "eprolo": "bin/eprolo-cli.js"