@things-factory/integration-marketplace 3.7.11 → 3.8.0
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/dist-server/controllers/lazada/apis/get-store-order-item-transaction-details.js +88 -0
- package/dist-server/controllers/lazada/apis/get-store-order-item-transaction-details.js.map +1 -0
- package/dist-server/controllers/lazada/apis/get-store-order-items.js +39 -7
- package/dist-server/controllers/lazada/apis/get-store-order-items.js.map +1 -1
- package/dist-server/controllers/lazada/apis/index.js +1 -1
- package/dist-server/controllers/lazada/apis/index.js.map +1 -1
- package/dist-server/controllers/lazada/client/lazada.js +24 -4
- package/dist-server/controllers/lazada/client/lazada.js.map +1 -1
- package/dist-server/controllers/lazada/platform-action.js +18 -3
- package/dist-server/controllers/lazada/platform-action.js.map +1 -1
- package/dist-server/controllers/store-api/index.js +28 -0
- package/dist-server/controllers/store-api/index.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/get-store-order.js +21 -0
- package/dist-server/controllers/woocommerce/apis/get-store-order.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/get-store-product-categories.js +8 -44
- package/dist-server/controllers/woocommerce/apis/get-store-product-categories.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/index.js +10 -0
- package/dist-server/controllers/woocommerce/apis/index.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/update-order.js +37 -0
- package/dist-server/controllers/woocommerce/apis/update-order.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/update-product-attribute.js +20 -0
- package/dist-server/controllers/woocommerce/apis/update-product-attribute.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-price.js +23 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-price.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-stock.js +2 -2
- package/dist-server/controllers/woocommerce/apis/update-store-product-stock.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/update-store-product-variant-price.js +20 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-variant-price.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-variant-stock.js +20 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-variant-stock.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-variation-price.js +23 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-variation-price.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/update-store-product-variation-stock.js +3 -3
- package/dist-server/controllers/woocommerce/apis/update-store-product-variation-stock.js.map +1 -1
- package/dist-server/controllers/woocommerce/woocommerce.js +2 -2
- package/dist-server/controllers/woocommerce/woocommerce.js.map +1 -1
- package/package.json +14 -14
- package/server/controllers/lazada/apis/get-store-order-item-transaction-details.ts +65 -0
- package/server/controllers/lazada/apis/get-store-order-items.ts +74 -6
- package/server/controllers/lazada/apis/index.ts +1 -1
- package/server/controllers/lazada/client/lazada.ts +42 -12
- package/server/controllers/lazada/platform-action.ts +20 -1
- package/server/controllers/store-api/index.ts +15 -2
- package/server/controllers/woocommerce/apis/get-store-order.ts +17 -0
- package/server/controllers/woocommerce/apis/get-store-product-categories.ts +6 -48
- package/server/controllers/woocommerce/apis/index.ts +10 -0
- package/server/controllers/woocommerce/apis/update-order.ts +36 -0
- package/server/controllers/woocommerce/apis/update-product-attribute.ts +17 -0
- package/server/controllers/woocommerce/apis/update-store-product-price.ts +20 -0
- package/server/controllers/woocommerce/apis/update-store-product-stock.ts +2 -2
- package/server/controllers/woocommerce/apis/update-store-product-variant-price.ts +17 -0
- package/server/controllers/woocommerce/apis/update-store-product-variant-stock.ts +18 -0
- package/server/controllers/woocommerce/apis/update-store-product-variation-price.ts +20 -0
- package/server/controllers/woocommerce/apis/update-store-product-variation-stock.ts +3 -3
- package/server/controllers/woocommerce/woocommerce.ts +2 -2
- package/dist-server/controllers/lazada/apis/get-store-order-item-payment-fee.js +0 -35
- package/dist-server/controllers/lazada/apis/get-store-order-item-payment-fee.js.map +0 -1
- package/server/controllers/lazada/apis/get-store-order-item-payment-fee.ts +0 -34
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product-attribute */
|
|
3
|
+
/* /wp-json/wc/v3/attributes/<id> */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.updateProductAttribute = void 0;
|
|
6
|
+
function updateProductAttribute(req) {
|
|
7
|
+
return {
|
|
8
|
+
method: 'put',
|
|
9
|
+
path: '/products/attributes/{attributeId}',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { name, attributeId } = req || {};
|
|
12
|
+
return { resource: { attributeId: attributeId }, payload: { name } };
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.updateProductAttribute = updateProductAttribute;
|
|
20
|
+
//# sourceMappingURL=update-product-attribute.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-product-attribute.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-product-attribute.ts"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,oCAAoC;;;AAEpC,SAAgB,sBAAsB,CAAC,GAAG;IACxC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,oCAAoC;QAC1C,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAErC,OAAO,EAAE,QAAQ,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,CAAA;QACtE,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAbD,wDAaC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#update-a-product */
|
|
3
|
+
/* /wp-json/wc/v3/products/<id> */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.updateStoreProductPrice = void 0;
|
|
6
|
+
function updateStoreProductPrice(req) {
|
|
7
|
+
return {
|
|
8
|
+
method: 'put',
|
|
9
|
+
path: '/products/{itemId}',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { costPrice, sellPrice, productId } = req || {};
|
|
12
|
+
return {
|
|
13
|
+
resource: { itemId: parseInt(productId) },
|
|
14
|
+
payload: { regular_price: costPrice === null || costPrice === void 0 ? void 0 : costPrice.toString(), sale_price: sellPrice === null || sellPrice === void 0 ? void 0 : sellPrice.toString() }
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
normalize(res) {
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.updateStoreProductPrice = updateStoreProductPrice;
|
|
23
|
+
//# sourceMappingURL=update-store-product-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-price.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-price.ts"],"names":[],"mappings":";AAAA,0FAA0F;AAC1F,kCAAkC;;;AAElC,SAAgB,uBAAuB,CAAC,GAAG;IACzC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,oBAAoB;QAC1B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEnD,OAAO;gBACL,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE;gBACzC,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,EAAE;aACrF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAhBD,0DAgBC"}
|
|
@@ -8,11 +8,11 @@ function updateStoreProductStock(req) {
|
|
|
8
8
|
method: 'put',
|
|
9
9
|
path: '/products/{itemId}',
|
|
10
10
|
denormalize(req) {
|
|
11
|
-
var { qty, itemId } = req
|
|
11
|
+
var { qty, itemId } = req || {};
|
|
12
12
|
return { resource: { itemId: parseInt(itemId) }, payload: { stock_quantity: qty, manage_stock: true } };
|
|
13
13
|
},
|
|
14
14
|
normalize(res) {
|
|
15
|
-
return res
|
|
15
|
+
return res;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,0FAA0F;AAC1F,kCAAkC;;;AAElC,SAAgB,uBAAuB,CAAC,GAAG;IACzC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,oBAAoB;QAC1B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,
|
|
1
|
+
{"version":3,"file":"update-store-product-stock.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-stock.ts"],"names":[],"mappings":";AAAA,0FAA0F;AAC1F,kCAAkC;;;AAElC,SAAgB,uBAAuB,CAAC,GAAG;IACzC,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,oBAAoB;QAC1B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAE/B,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CAAA;QACzG,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAbD,0DAaC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#update-a-product-variation */
|
|
3
|
+
/* /wp-json/wc/v3/products/<product_id>/variations/<id> */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.updateStoreProductVariantPrice = void 0;
|
|
6
|
+
function updateStoreProductVariantPrice(req) {
|
|
7
|
+
return {
|
|
8
|
+
method: 'put',
|
|
9
|
+
path: '/products/{itemId}/variations/{variantId}',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { cost_price, sell_price, product_id, variant_id } = req[0] || {};
|
|
12
|
+
return { resource: { itemId: parseInt(product_id), variantId: parseInt(variant_id) }, payload: { price: cost_price, sale_price: sell_price } };
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res.items;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.updateStoreProductVariantPrice = updateStoreProductVariantPrice;
|
|
20
|
+
//# sourceMappingURL=update-store-product-variant-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-variant-price.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-variant-price.ts"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,0DAA0D;;;AAE1D,SAAgB,8BAA8B,CAAC,GAAG;IAChD,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,2CAA2C;QACjD,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;YAErE,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,EAAE,CAAA;QAChJ,CAAC;QACD,SAAS,CAAC,GAAG;YACT,OAAO,GAAG,CAAC,KAAK,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC;AAbD,wEAaC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#update-a-product-variation */
|
|
3
|
+
/* /wp-json/wc/v3/products/<product_id>/variations/<id> */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.updateStoreProductVariantStock = void 0;
|
|
6
|
+
function updateStoreProductVariantStock(req) {
|
|
7
|
+
return {
|
|
8
|
+
method: 'put',
|
|
9
|
+
path: '/products/{itemId}/variations/{variantId}',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { qty, product_id, variant_id } = req[0] || {};
|
|
12
|
+
return { resource: { itemId: parseInt(product_id), variantId: parseInt(variant_id) }, payload: { stock_quantity: qty, manage_stock: true } };
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res.items;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
exports.updateStoreProductVariantStock = updateStoreProductVariantStock;
|
|
20
|
+
//# sourceMappingURL=update-store-product-variant-stock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-variant-stock.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-variant-stock.ts"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,0DAA0D;;;AAE1D,SAAgB,8BAA8B,CAAC,GAAG;IAC9C,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,2CAA2C;QACjD,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;YAElD,OAAO,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CAAA;QAC9I,CAAC;QACD,SAAS,CAAC,GAAG;YACT,OAAO,GAAG,CAAC,KAAK,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC;AAbH,wEAaG"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#update-a-product-variation */
|
|
3
|
+
/* /wp-json/wc/v3/products/<product_id>/variations/<id> */
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.updateStoreProductVariationPrice = void 0;
|
|
6
|
+
function updateStoreProductVariationPrice(req) {
|
|
7
|
+
return {
|
|
8
|
+
method: 'put',
|
|
9
|
+
path: '/products/{itemId}/variations/{variantId}',
|
|
10
|
+
denormalize(req) {
|
|
11
|
+
var { costPrice, sellPrice, productId, variationId } = req || {};
|
|
12
|
+
return {
|
|
13
|
+
resource: { itemId: parseInt(productId), variantId: parseInt(variationId) },
|
|
14
|
+
payload: { regular_price: costPrice === null || costPrice === void 0 ? void 0 : costPrice.toString(), sale_price: sellPrice === null || sellPrice === void 0 ? void 0 : sellPrice.toString() }
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
normalize(res) {
|
|
18
|
+
return res;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.updateStoreProductVariationPrice = updateStoreProductVariationPrice;
|
|
23
|
+
//# sourceMappingURL=update-store-product-variation-price.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-store-product-variation-price.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-variation-price.ts"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,0DAA0D;;;AAE1D,SAAgB,gCAAgC,CAAC,GAAG;IAClD,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,2CAA2C;QACjD,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEhE,OAAO;gBACL,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;gBAC3E,OAAO,EAAE,EAAE,aAAa,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,QAAQ,EAAE,EAAE;aACrF,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAhBD,4EAgBC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#update-a-product */
|
|
2
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#update-a-product-variation */
|
|
3
3
|
/* /wp-json/wc/v3/products/<product_id>/variations/<id> */
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.updateStoreProductVariationStock = void 0;
|
|
@@ -8,14 +8,14 @@ function updateStoreProductVariationStock(req) {
|
|
|
8
8
|
method: 'put',
|
|
9
9
|
path: '/products/{itemId}/variations/{variationId}',
|
|
10
10
|
denormalize(req) {
|
|
11
|
-
var { qty, itemId, variationId } = req
|
|
11
|
+
var { qty, itemId, variationId } = req || {};
|
|
12
12
|
return {
|
|
13
13
|
resource: { itemId: parseInt(itemId), variationId: parseInt(variationId) },
|
|
14
14
|
payload: { stock_quantity: qty, manage_stock: true }
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
17
|
normalize(res) {
|
|
18
|
-
return res
|
|
18
|
+
return res;
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
}
|
package/dist-server/controllers/woocommerce/apis/update-store-product-variation-stock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,
|
|
1
|
+
{"version":3,"file":"update-store-product-variation-stock.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/update-store-product-variation-stock.ts"],"names":[],"mappings":";AAAA,oGAAoG;AACpG,0DAA0D;;;AAE1D,SAAgB,gCAAgC,CAAC,GAAG;IAClD,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,6CAA6C;QACnD,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAE5C,OAAO;gBACL,QAAQ,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;gBAC1E,OAAO,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE;aACrD,CAAA;QACH,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAA;QACZ,CAAC;KACF,CAAA;AACH,CAAC;AAhBD,4EAgBC"}
|
|
@@ -16,11 +16,11 @@ class Woocommerce {
|
|
|
16
16
|
* X-WP-Total is to get the total items from the response
|
|
17
17
|
*/
|
|
18
18
|
async get(path, data) {
|
|
19
|
-
const { consumer_key, consumer_secret, storeURL } = this.config;
|
|
19
|
+
const { consumer_key, consumer_secret, storeURL, queryStringAuth } = this.config;
|
|
20
20
|
const qs = Object.entries(data)
|
|
21
21
|
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
22
22
|
.join('&');
|
|
23
|
-
const endpoint = `${storeURL}/wp-json/wc/v3${path}?consumer_key=${consumer_key}&consumer_secret=${consumer_secret}
|
|
23
|
+
const endpoint = `${storeURL}/wp-json/wc/v3${path}?consumer_key=${consumer_key}&consumer_secret=${consumer_secret}&query_string_auth=${queryStringAuth}&${qs ? '&' + qs : ''}`;
|
|
24
24
|
debug('endpoint', endpoint);
|
|
25
25
|
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
26
26
|
headers: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"woocommerce.js","sourceRoot":"","sources":["../../../server/controllers/woocommerce/woocommerce.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA8B;AAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,oDAAoD,CAAC,CAAA;AASpF,MAAa,WAAW;IAGtB,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,qBACN,MAAM,CACV,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,IAAS;QAC/B,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"woocommerce.js","sourceRoot":"","sources":["../../../server/controllers/woocommerce/woocommerce.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-marketplace",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"test": "DEBUG=things-factory:* NODE_ENV=development npx mocha -r ts-node/register ./test/**/*spec.ts"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@things-factory/apptool-ui": "^3.
|
|
29
|
-
"@things-factory/auth-ui": "^3.
|
|
30
|
-
"@things-factory/biz-base": "^3.
|
|
31
|
-
"@things-factory/code-ui": "^3.
|
|
32
|
-
"@things-factory/context-ui": "^3.
|
|
28
|
+
"@things-factory/apptool-ui": "^3.8.0",
|
|
29
|
+
"@things-factory/auth-ui": "^3.8.0",
|
|
30
|
+
"@things-factory/biz-base": "^3.8.0",
|
|
31
|
+
"@things-factory/code-ui": "^3.8.0",
|
|
32
|
+
"@things-factory/context-ui": "^3.8.0",
|
|
33
33
|
"@things-factory/grist-ui": "^3.7.5",
|
|
34
|
-
"@things-factory/i18n-ui": "^3.
|
|
35
|
-
"@things-factory/integration-lmd": "^3.
|
|
36
|
-
"@things-factory/integration-ui": "^3.
|
|
37
|
-
"@things-factory/more-ui": "^3.
|
|
38
|
-
"@things-factory/resource-ui": "^3.
|
|
39
|
-
"@things-factory/setting-ui": "^3.
|
|
40
|
-
"@things-factory/system-ui": "^3.
|
|
34
|
+
"@things-factory/i18n-ui": "^3.8.0",
|
|
35
|
+
"@things-factory/integration-lmd": "^3.8.0",
|
|
36
|
+
"@things-factory/integration-ui": "^3.8.0",
|
|
37
|
+
"@things-factory/more-ui": "^3.8.0",
|
|
38
|
+
"@things-factory/resource-ui": "^3.8.0",
|
|
39
|
+
"@things-factory/setting-ui": "^3.8.0",
|
|
40
|
+
"@things-factory/system-ui": "^3.8.0",
|
|
41
41
|
"debug": "^4.1.1",
|
|
42
42
|
"node-fetch": "^2.6.0",
|
|
43
43
|
"querystring": "^0.2.1"
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"nock": "^13.0.2",
|
|
54
54
|
"should": "^13.2.3"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "d3a61edb1a77732db20185aedc47b2cce6dd1f82"
|
|
57
57
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* https://open.lazada.com/doc/api.htm?spm=a2o9m.11193531.0.0.4f406bbetGwYgx#/api?cid=9&path=/finance/transaction/details/get */
|
|
2
|
+
|
|
3
|
+
export function getStoreOrderItemTransactionDetails() {
|
|
4
|
+
return {
|
|
5
|
+
method: 'get',
|
|
6
|
+
path: '/finance/transaction/details/get',
|
|
7
|
+
denormalize(req) {
|
|
8
|
+
var { orderItemId, orderCreatedAt } = req
|
|
9
|
+
let startDate = new Date(orderCreatedAt)
|
|
10
|
+
let endDate = new Date(orderCreatedAt)
|
|
11
|
+
endDate.setDate(endDate.getDate() + 14)
|
|
12
|
+
let currentDate = new Date()
|
|
13
|
+
if (endDate > currentDate) {
|
|
14
|
+
endDate = currentDate
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
start_time: startDate.toISOString().replace(/T.*/, '').split('-').join('-'),
|
|
19
|
+
end_time: endDate.toISOString().replace(/T.*/, '').split('-').join('-'),
|
|
20
|
+
trade_order_line_id: orderItemId
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
normalize(res) {
|
|
24
|
+
let payment_fee = 0
|
|
25
|
+
let commission_fee = 0
|
|
26
|
+
let promotional_charges = 0
|
|
27
|
+
let shipping_fee_paid_by_customer = 0
|
|
28
|
+
let item_price_credit = 0
|
|
29
|
+
let orders_marketplace_fees_total = 0
|
|
30
|
+
let orders_sales_total = 0
|
|
31
|
+
let orders_marketing_fees_total = 0
|
|
32
|
+
let orders_logistics_total = 0
|
|
33
|
+
let promotional_charges_flexi_combo = 0
|
|
34
|
+
let auto_shipping_subsidy_marketplace = 0
|
|
35
|
+
|
|
36
|
+
res.forEach(item => {
|
|
37
|
+
if (item.fee_name == 'Payment Fee') { payment_fee += parseFloat(item.amount) || 0 }
|
|
38
|
+
if (item.fee_name == 'Commission') { commission_fee += parseFloat(item.amount) || 0 }
|
|
39
|
+
if (item.fee_name == 'Item Price Credit') { item_price_credit += parseFloat(item.amount) || 0 }
|
|
40
|
+
if (item.fee_name == 'Promotional Charges Vouchers') { promotional_charges += parseFloat(item.amount) || 0 }
|
|
41
|
+
if (item.fee_name == 'Shipping Fee (Paid By Customer)') { shipping_fee_paid_by_customer += parseFloat(item.amount) || 0 }
|
|
42
|
+
if (item.fee_name == 'Promotional Charges Flexi-Combo') { promotional_charges_flexi_combo += parseFloat(item.amount) || 0 }
|
|
43
|
+
if (item.fee_name == 'Auto. Shipping fee subsidy (by Lazada)') { auto_shipping_subsidy_marketplace += parseFloat(item.amount) || 0 }
|
|
44
|
+
|
|
45
|
+
if (item.transaction_type == 'Orders-Lazada Fees') { orders_marketplace_fees_total += parseFloat(item.amount) || 0 }
|
|
46
|
+
if (item.transaction_type == 'Orders-Sales') { orders_sales_total += parseFloat(item.amount) || 0 }
|
|
47
|
+
if (item.transaction_type == 'Orders-Marketing Fees') { orders_marketing_fees_total += parseFloat(item.amount) || 0 }
|
|
48
|
+
if (item.transaction_type == 'Orders-Logistics') { orders_logistics_total += parseFloat(item.amount) || 0 }
|
|
49
|
+
})
|
|
50
|
+
return {
|
|
51
|
+
payment_fee: Math.trunc(payment_fee * 100) / 100,
|
|
52
|
+
commission_fee: Math.trunc(commission_fee * 100) / 100,
|
|
53
|
+
promotional_charges: Math.trunc(promotional_charges * 100) / 100,
|
|
54
|
+
shipping_fee_paid_by_customer: Math.trunc(shipping_fee_paid_by_customer * 100) / 100,
|
|
55
|
+
item_price_credit: Math.trunc(item_price_credit * 100) / 100,
|
|
56
|
+
orders_marketplace_fees_total: Math.trunc(orders_marketplace_fees_total * 100) / 100,
|
|
57
|
+
orders_sales_total: Math.trunc(orders_sales_total * 100) / 100,
|
|
58
|
+
orders_marketing_fees_total: Math.trunc(orders_marketing_fees_total * 100) / 100,
|
|
59
|
+
orders_logistics_total: Math.trunc(orders_logistics_total * 100) / 100,
|
|
60
|
+
promotional_charges_flexi_combo: Math.trunc(promotional_charges_flexi_combo * 100) / 100,
|
|
61
|
+
auto_shipping_subsidy_marketplace: Math.trunc(auto_shipping_subsidy_marketplace * 100) / 100
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -20,8 +20,11 @@ export function getStoreOrderItems() {
|
|
|
20
20
|
orderItemId: item.order_item_id,
|
|
21
21
|
orderCreatedAt: item.created_at
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
res[i]
|
|
23
|
+
let transactionDetails = await StoreAPI.getStoreOrderItemTransactionDetails(store, req)
|
|
24
|
+
res[i] = {
|
|
25
|
+
...res[i],
|
|
26
|
+
...transactionDetails
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
let results = res
|
|
@@ -41,12 +44,28 @@ export function getStoreOrderItems() {
|
|
|
41
44
|
paid_price: item.paid_price,
|
|
42
45
|
item_price: item.item_price,
|
|
43
46
|
payment_fee: item.payment_fee,
|
|
47
|
+
commission_fee: item.commission_fee,
|
|
48
|
+
promotional_charges: item.promotional_charges,
|
|
49
|
+
shipping_fee_paid_by_customer: item.shipping_fee_paid_by_customer,
|
|
50
|
+
item_price_credit: item.item_price_credit,
|
|
51
|
+
orders_marketplace_fees_total: item.orders_marketplace_fees_total,
|
|
52
|
+
orders_sales_total: item.orders_sales_total,
|
|
53
|
+
orders_marketing_fees_total: item.orders_marketing_fees_total,
|
|
54
|
+
orders_logistics_total: item.orders_logistics_total,
|
|
44
55
|
qty: 1,
|
|
45
56
|
shipment_provider: item.shipment_provider,
|
|
46
57
|
tracking_code: JSON.stringify(
|
|
47
58
|
item.tracking_code ? [{ order_item_id: item.order_item_id, tracking_code: item.tracking_code }] : []
|
|
48
59
|
),
|
|
49
|
-
status: item.status
|
|
60
|
+
status: item.status,
|
|
61
|
+
voucher_platform_lpi: item.voucher_platform_lpi,
|
|
62
|
+
voucher_seller_lpi: item.voucher_seller_lpi,
|
|
63
|
+
shipping_fee_discount_platform: item.shipping_fee_discount_platform,
|
|
64
|
+
shipping_fee_discount_seller: item.shipping_fee_discount_seller,
|
|
65
|
+
promotional_charges_flexi_combo: item.promotional_charges_flexi_combo,
|
|
66
|
+
auto_shipping_subsidy_marketplace: item.auto_shipping_subsidy_marketplace,
|
|
67
|
+
shipping_fee_original: item.shipping_fee_original,
|
|
68
|
+
tax_amount: item.tax_amount
|
|
50
69
|
}
|
|
51
70
|
|
|
52
71
|
newItem.push(data)
|
|
@@ -58,12 +77,29 @@ export function getStoreOrderItems() {
|
|
|
58
77
|
qty: existingItem.qty + 1,
|
|
59
78
|
paid_price: item.paid_price + existingItem.paid_price,
|
|
60
79
|
item_price: item.item_price + existingItem.item_price,
|
|
80
|
+
payment_fee: item.payment_fee + existingItem.payment_fee,
|
|
81
|
+
commission_fee: item.commission_fee + existingItem.commission_fee,
|
|
82
|
+
promotional_charges: item.promotional_charges + existingItem.promotional_charges,
|
|
83
|
+
shipping_fee_paid_by_customer: item.shipping_fee_paid_by_customer + existingItem.shipping_fee_paid_by_customer,
|
|
84
|
+
item_price_credit: item.item_price_credit + existingItem.item_price_credit,
|
|
85
|
+
orders_marketplace_fees_total: item.orders_marketplace_fees_total + existingItem.orders_marketplace_fees_total,
|
|
86
|
+
orders_sales_total: item.orders_sales_total + existingItem.orders_sales_total,
|
|
87
|
+
orders_marketing_fees_total: item.orders_marketing_fees_total + existingItem.orders_marketing_fees_total,
|
|
88
|
+
orders_logistics_total: item.orders_logistics_total + existingItem.orders_logistics_total,
|
|
61
89
|
tracking_code: item.tracking_code
|
|
62
90
|
? JSON.stringify([
|
|
63
91
|
...JSON.parse(existingItem.tracking_code),
|
|
64
92
|
{ order_item_id: item.order_item_id, tracking_code: item.tracking_code }
|
|
65
93
|
])
|
|
66
|
-
: existingItem.tracking_code
|
|
94
|
+
: existingItem.tracking_code,
|
|
95
|
+
voucher_platform_lpi: item.voucher_platform_lpi + existingItem.voucher_platform_lpi,
|
|
96
|
+
voucher_seller_lpi: item.voucher_seller_lpi + existingItem.voucher_seller_lpi,
|
|
97
|
+
shipping_fee_discount_platform: item.shipping_fee_discount_platform + existingItem.shipping_fee_discount_platform,
|
|
98
|
+
shipping_fee_discount_seller: item.shipping_fee_discount_seller + existingItem.shipping_fee_discount_seller,
|
|
99
|
+
promotional_charges_flexi_combo: item.promotional_charges_flexi_combo + existingItem.promotional_charges_flexi_combo,
|
|
100
|
+
auto_shipping_subsidy_marketplace: item.auto_shipping_subsidy_marketplace + existingItem.auto_shipping_subsidy_marketplace,
|
|
101
|
+
shipping_fee_original: item.shipping_fee_original + existingItem.shipping_fee_original,
|
|
102
|
+
tax_amount: item.tax_amount + existingItem.tax_amount
|
|
67
103
|
}
|
|
68
104
|
}
|
|
69
105
|
return newItem
|
|
@@ -83,7 +119,23 @@ export function getStoreOrderItems() {
|
|
|
83
119
|
tracking_code,
|
|
84
120
|
status,
|
|
85
121
|
item_price: originalPrice,
|
|
86
|
-
payment_fee: paymentFee
|
|
122
|
+
payment_fee: paymentFee,
|
|
123
|
+
commission_fee: commissionFee,
|
|
124
|
+
promotional_charges: promotionalCharges,
|
|
125
|
+
shipping_fee_paid_by_customer: shippingFeePaidByCustomer,
|
|
126
|
+
item_price_credit: itemPriceCredit,
|
|
127
|
+
orders_marketplace_fees_total: ordersMarketplaceFeesTotal,
|
|
128
|
+
orders_sales_total: ordersSalesTotal,
|
|
129
|
+
orders_marketing_fees_total: ordersMarketingFeesTotal,
|
|
130
|
+
orders_logistics_total: ordersLogisticsTotal,
|
|
131
|
+
voucher_platform_lpi: marketplaceBonus,
|
|
132
|
+
voucher_seller_lpi: marketplaceBonusSeller,
|
|
133
|
+
shipping_fee_discount_platform: shippingFeeDiscountMarketplace,
|
|
134
|
+
shipping_fee_discount_seller: shippingFeeDiscountSeller,
|
|
135
|
+
promotional_charges_flexi_combo: promotionalChargesFlexiCombo,
|
|
136
|
+
auto_shipping_subsidy_marketplace: autoShippingSubsidyMarketplace,
|
|
137
|
+
shipping_fee_original: originalShippingFee,
|
|
138
|
+
tax_amount: taxAmount
|
|
87
139
|
} = orderItem
|
|
88
140
|
var trackingNo = tracking_code === '' ? null : tracking_code
|
|
89
141
|
|
|
@@ -101,7 +153,23 @@ export function getStoreOrderItems() {
|
|
|
101
153
|
trackingNo,
|
|
102
154
|
status,
|
|
103
155
|
originalPrice,
|
|
104
|
-
paymentFee
|
|
156
|
+
paymentFee,
|
|
157
|
+
commissionFee,
|
|
158
|
+
promotionalCharges,
|
|
159
|
+
shippingFeePaidByCustomer,
|
|
160
|
+
itemPriceCredit,
|
|
161
|
+
ordersMarketplaceFeesTotal,
|
|
162
|
+
ordersSalesTotal,
|
|
163
|
+
ordersMarketingFeesTotal,
|
|
164
|
+
ordersLogisticsTotal,
|
|
165
|
+
marketplaceBonus,
|
|
166
|
+
marketplaceBonusSeller,
|
|
167
|
+
shippingFeeDiscountMarketplace,
|
|
168
|
+
shippingFeeDiscountSeller,
|
|
169
|
+
promotionalChargesFlexiCombo,
|
|
170
|
+
autoShippingSubsidyMarketplace,
|
|
171
|
+
originalShippingFee,
|
|
172
|
+
taxAmount
|
|
105
173
|
}
|
|
106
174
|
})
|
|
107
175
|
|
|
@@ -21,4 +21,4 @@ export * from './update-store-product-stock'
|
|
|
21
21
|
export * from './update-store-product-variation-stock'
|
|
22
22
|
export * from './update-store-product'
|
|
23
23
|
export * from './get-store-refund-orders'
|
|
24
|
-
export * from './get-store-order-item-
|
|
24
|
+
export * from './get-store-order-item-transaction-details'
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import FormData from 'form-data'
|
|
1
2
|
import fetch from 'node-fetch'
|
|
2
|
-
import {
|
|
3
|
+
import { getRepository } from 'typeorm'
|
|
4
|
+
|
|
5
|
+
import { MarketplaceStore } from '../../../entities'
|
|
3
6
|
import { makeSystemParameters } from './signature'
|
|
7
|
+
import { Endpoint, Parameter } from './types'
|
|
4
8
|
import { xmlize } from './xml'
|
|
5
|
-
import FormData from 'form-data'
|
|
6
9
|
|
|
7
10
|
export class Lazada {
|
|
8
11
|
endpoint: string
|
|
@@ -38,13 +41,13 @@ export class Lazada {
|
|
|
38
41
|
return await response.json()
|
|
39
42
|
}
|
|
40
43
|
|
|
41
|
-
async refreshAccessToken(payload: { refresh_token: string }) {
|
|
44
|
+
public static async refreshAccessToken(payload: { refresh_token: string }, appKey, appSecret, storeId) {
|
|
42
45
|
/* CONFIRM-ME not qualified */
|
|
43
46
|
const apiPath = '/auth/token/refresh'
|
|
44
47
|
|
|
45
48
|
const body = {
|
|
46
49
|
...payload,
|
|
47
|
-
...makeSystemParameters(
|
|
50
|
+
...makeSystemParameters(appKey, appSecret, apiPath, undefined, payload)
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
const response = await fetch(Endpoint.auth + apiPath, {
|
|
@@ -55,6 +58,25 @@ export class Lazada {
|
|
|
55
58
|
body: JSON.stringify(body)
|
|
56
59
|
})
|
|
57
60
|
|
|
61
|
+
const repository = getRepository(MarketplaceStore)
|
|
62
|
+
const store: MarketplaceStore = await repository.findOne({
|
|
63
|
+
where: { id: storeId }
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const refreshTokenInfo = await response.json()
|
|
67
|
+
const { access_token, refresh_token } = refreshTokenInfo
|
|
68
|
+
|
|
69
|
+
var patch = {
|
|
70
|
+
accessToken: access_token,
|
|
71
|
+
refreshToken: refresh_token,
|
|
72
|
+
accessInfo: JSON.stringify(refreshTokenInfo, null, 2)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
await repository.save({
|
|
76
|
+
...store,
|
|
77
|
+
...patch
|
|
78
|
+
})
|
|
79
|
+
|
|
58
80
|
return await response.json()
|
|
59
81
|
}
|
|
60
82
|
|
|
@@ -72,6 +94,10 @@ export class Lazada {
|
|
|
72
94
|
}
|
|
73
95
|
})
|
|
74
96
|
|
|
97
|
+
if (!response.ok) {
|
|
98
|
+
throw response
|
|
99
|
+
}
|
|
100
|
+
|
|
75
101
|
return await response.json()
|
|
76
102
|
}
|
|
77
103
|
|
|
@@ -80,13 +106,13 @@ export class Lazada {
|
|
|
80
106
|
params.payload = xmlize(params.payload)
|
|
81
107
|
}
|
|
82
108
|
|
|
83
|
-
const {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
109
|
+
const { app_key, timestamp, access_token, sign_method, sign } = makeSystemParameters(
|
|
110
|
+
this.appKey,
|
|
111
|
+
this.appSecret,
|
|
112
|
+
path,
|
|
113
|
+
accessToken || this.accessToken,
|
|
114
|
+
params
|
|
115
|
+
)
|
|
90
116
|
|
|
91
117
|
const body = new FormData()
|
|
92
118
|
|
|
@@ -96,7 +122,7 @@ export class Lazada {
|
|
|
96
122
|
body.append('sign_method', sign_method)
|
|
97
123
|
body.append('sign', sign)
|
|
98
124
|
|
|
99
|
-
for(let key in params) {
|
|
125
|
+
for (let key in params) {
|
|
100
126
|
body.append(key, params[key])
|
|
101
127
|
}
|
|
102
128
|
|
|
@@ -106,6 +132,10 @@ export class Lazada {
|
|
|
106
132
|
body
|
|
107
133
|
})
|
|
108
134
|
|
|
135
|
+
if (!response.ok) {
|
|
136
|
+
throw response
|
|
137
|
+
}
|
|
138
|
+
|
|
109
139
|
return await response.json()
|
|
110
140
|
}
|
|
111
141
|
}
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
import { config } from '@things-factory/env'
|
|
2
|
+
|
|
1
3
|
import { Lazada } from './client'
|
|
2
4
|
|
|
3
|
-
import { config } from '@things-factory/env'
|
|
4
5
|
const lazadaConfig = config.get('marketplaceIntegrationLazada', {})
|
|
5
6
|
const { appKey, appSecret } = lazadaConfig
|
|
6
7
|
|
|
7
8
|
export const action = async ({ store, method = 'get', path, request }) => {
|
|
9
|
+
try {
|
|
10
|
+
return await _action({ store, method, path, request })
|
|
11
|
+
} catch (ex) {
|
|
12
|
+
if (ex.code === 'IllegalAccessToken') {
|
|
13
|
+
var refreshStore = await Lazada.refreshAccessToken(
|
|
14
|
+
{ refresh_token: store.refreshToken },
|
|
15
|
+
appKey,
|
|
16
|
+
appSecret,
|
|
17
|
+
store.id
|
|
18
|
+
)
|
|
19
|
+
return await _action({ store: refreshStore, method, path, request })
|
|
20
|
+
} else {
|
|
21
|
+
throw ex
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const _action = async ({ store, method = 'get', path, request }) => {
|
|
8
27
|
const client = new Lazada(store.countryCode, appKey, appSecret)
|
|
9
28
|
|
|
10
29
|
var response = await client[method == 'post' ? 'post' : 'get'](path, request, store.accessToken)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getRepository } from 'typeorm'
|
|
2
|
+
|
|
2
3
|
import { MarketplaceStore } from '../../entities'
|
|
3
4
|
import { api } from './decorators'
|
|
4
5
|
|
|
@@ -80,6 +81,9 @@ export class StoreAPI {
|
|
|
80
81
|
@api
|
|
81
82
|
static updateStoreProduct(store, req): any {}
|
|
82
83
|
|
|
84
|
+
@api
|
|
85
|
+
static updateOrder(store, req): any {}
|
|
86
|
+
|
|
83
87
|
@api
|
|
84
88
|
static cancelStoreOrder(store, req): any {}
|
|
85
89
|
|
|
@@ -156,14 +160,23 @@ export class StoreAPI {
|
|
|
156
160
|
static getStoreRefundOrders(store, req): any {}
|
|
157
161
|
|
|
158
162
|
@api
|
|
159
|
-
static getStoreRefundOrderDetails(store, req): any{}
|
|
163
|
+
static getStoreRefundOrderDetails(store, req): any {}
|
|
164
|
+
|
|
165
|
+
@api
|
|
166
|
+
static getStoreOrderItemPaymentFee(store, req): any {}
|
|
160
167
|
|
|
161
168
|
@api
|
|
162
|
-
static
|
|
169
|
+
static getStoreOrderItemTransactionDetails(store, req): any {}
|
|
163
170
|
|
|
164
171
|
@api
|
|
165
172
|
static updateProductAttribute(store, req): any {}
|
|
166
173
|
|
|
167
174
|
@api
|
|
168
175
|
static getStoreOrderTransactionDetails(store, req): any {}
|
|
176
|
+
|
|
177
|
+
@api
|
|
178
|
+
static updateStoreProductVariationPrice(store, req): any {}
|
|
179
|
+
|
|
180
|
+
@api
|
|
181
|
+
static updateStoreProductPrice(store, req): any {}
|
|
169
182
|
}
|