@things-factory/integration-marketplace 3.6.48 → 3.6.52
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/woocommerce/apis/create-order-note.js +3 -3
- package/dist-server/controllers/woocommerce/apis/create-order-note.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/get-store-orders.js +22 -11
- package/dist-server/controllers/woocommerce/apis/get-store-orders.js.map +1 -1
- package/dist-server/controllers/woocommerce/platform-action.js +2 -2
- package/dist-server/controllers/woocommerce/platform-action.js.map +1 -1
- package/dist-server/controllers/woocommerce/woocommerce.js +4 -4
- package/dist-server/controllers/woocommerce/woocommerce.js.map +1 -1
- package/package.json +15 -15
- package/server/controllers/woocommerce/apis/create-order-note.ts +3 -3
- package/server/controllers/woocommerce/apis/get-store-orders.ts +48 -11
- package/server/controllers/woocommerce/platform-action.ts +3 -2
- package/server/controllers/woocommerce/woocommerce.ts +4 -4
|
@@ -6,10 +6,10 @@ exports.createOrderNote = void 0;
|
|
|
6
6
|
function createOrderNote(req) {
|
|
7
7
|
return {
|
|
8
8
|
method: 'post',
|
|
9
|
-
path: '/orders/{orderId}
|
|
9
|
+
path: '/orders/{orderId}/notes',
|
|
10
10
|
denormalize(req) {
|
|
11
|
-
var { note } = req || {};
|
|
12
|
-
return { resource: { orderId:
|
|
11
|
+
var { note, orderId } = req || {};
|
|
12
|
+
return { resource: { orderId: orderId }, payload: { note, customer_note: true } };
|
|
13
13
|
},
|
|
14
14
|
normalize(res) {
|
|
15
15
|
return res.items;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order-note.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/create-order-note.ts"],"names":[],"mappings":";AAAA,8FAA8F;AAC9F,2BAA2B;;;AAE3B,SAAgB,eAAe,CAAC,GAAG;IACjC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"create-order-note.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/create-order-note.ts"],"names":[],"mappings":";AAAA,8FAA8F;AAC9F,2BAA2B;;;AAE3B,SAAgB,eAAe,CAAC,GAAG;IACjC,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAEjC,OAAO,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,EAAE,CAAA;QACnF,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,GAAG,CAAC,KAAK,CAAA;QAClB,CAAC;KACF,CAAA;AACH,CAAC;AAbD,0CAaC"}
|
|
@@ -25,11 +25,11 @@ function getStoreOrders() {
|
|
|
25
25
|
},
|
|
26
26
|
async normalize(res, { store }) {
|
|
27
27
|
// return res.orders
|
|
28
|
-
var { items: orders, totalItems
|
|
28
|
+
var { items: orders, totalItems } = res;
|
|
29
29
|
let results = [];
|
|
30
30
|
for (var i = 0; i < orders.length; i++) {
|
|
31
31
|
const order = orders[i];
|
|
32
|
-
const { id: name,
|
|
32
|
+
const { id: name, number: orderNo, currency, total: totalAmount, payment_method: paymentMethod, status, discount_total: discountValue, date_created_gmt, date_modified_gmt, shipping, billing, line_items } = order;
|
|
33
33
|
let docRefNo = orderNo;
|
|
34
34
|
var orderCreatedAt = new Date(date_created_gmt).toUTCString();
|
|
35
35
|
var orderUpdatedAt = new Date(date_modified_gmt).toUTCString();
|
|
@@ -46,20 +46,31 @@ function getStoreOrders() {
|
|
|
46
46
|
discountValue
|
|
47
47
|
};
|
|
48
48
|
});
|
|
49
|
-
const { address_1, address_2, postcode:
|
|
49
|
+
const { address_1: shippingAddress1, address_2: shippingAddress2, postcode: shippingPostCode, country: shippingCountry, city: shippingCity, first_name: shippingFirstName, last_name: shippingLastName, state: shippingState, phone: shippingPhone, email: shippingEmail } = shipping;
|
|
50
|
+
const { address_1: billingAddress1, address_2: billingAddress2, postcode: billingPostCode, country: billingCountry, city: billingCity, first_name: billingFirstName, last_name: billingLastName, state: billingState, phone: billingPhone, email: billingEmail } = billing;
|
|
50
51
|
var orderShipping = {
|
|
51
|
-
address1:
|
|
52
|
-
address2:
|
|
52
|
+
address1: shippingAddress1 == null ? billingAddress1 : shippingAddress1,
|
|
53
|
+
address2: shippingAddress2 == null ? billingAddress2 : shippingAddress2,
|
|
53
54
|
address3: null,
|
|
54
55
|
address4: null,
|
|
55
56
|
address5: null,
|
|
56
|
-
phone1: null,
|
|
57
|
+
phone1: shippingPhone == null || shippingPhone == '' ? billingPhone : shippingPhone,
|
|
57
58
|
phone2: null,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
email: shippingEmail == null ? billingEmail : shippingEmail,
|
|
60
|
+
postCode: shippingPostCode == null ? billingPostCode : shippingPostCode,
|
|
61
|
+
city: shippingCity == null ? billingCity : shippingCity,
|
|
62
|
+
state: shippingState == null ? billingState : shippingState,
|
|
63
|
+
country: shippingCountry == null
|
|
64
|
+
? billingCountry === 'MY'
|
|
65
|
+
? 'Malaysia'
|
|
66
|
+
: billingCountry
|
|
67
|
+
: billingCountry === 'MY'
|
|
68
|
+
? 'Malaysia'
|
|
69
|
+
: billingCountry,
|
|
61
70
|
collectionCurrency: currency,
|
|
62
|
-
attentionTo:
|
|
71
|
+
attentionTo: shippingFirstName == null
|
|
72
|
+
? `${billingFirstName} ${billingLastName}`
|
|
73
|
+
: `${shippingFirstName} ${shippingLastName}`
|
|
63
74
|
};
|
|
64
75
|
results.push({
|
|
65
76
|
name,
|
|
@@ -68,7 +79,7 @@ function getStoreOrders() {
|
|
|
68
79
|
orderCreatedAt,
|
|
69
80
|
orderUpdatedAt,
|
|
70
81
|
totalAmount,
|
|
71
|
-
itemCount,
|
|
82
|
+
itemCount: line_items.length,
|
|
72
83
|
orderItems,
|
|
73
84
|
orderShipping
|
|
74
85
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,2BAA2B;;;AAE3B,SAAgB,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,WAAW,CAAC,GAAG;YACb,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,GAAG,IAAI,EAAE,CAAA;YAChD,IAAI,EAAE,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,GAAG,EAAE,GAAG,UAAU,IAAI,EAAE,CAAA;YAEhD,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,WAAW,EAAE,CAAA;YAC5C,IAAI,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;YAC3C,kEAAkE;YAClE,oCAAoC;YACpC,2BAA2B;YAE3B,IAAI,OAAO,GAAG;gBACZ,MAAM,EAAE,IAAI,GAAG,KAAK;gBACpB,KAAK;gBACL,KAAK;gBACL,MAAM;aACP,CAAA;YAED,OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;QACD,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE;YAC5B,oBAAoB;YACpB,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"get-store-orders.js","sourceRoot":"","sources":["../../../../server/controllers/woocommerce/apis/get-store-orders.ts"],"names":[],"mappings":";AAAA,yFAAyF;AACzF,2BAA2B;;;AAE3B,SAAgB,cAAc;IAC5B,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,SAAS;QACf,WAAW,CAAC,GAAG;YACb,I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OAAO,EAAE,OAAO,EAAE,CAAA;QACpB,CAAC;KACF,CAAA;AACH,CAAC;AAtID,wCAsIC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.action = void 0;
|
|
4
|
-
const woocommerce_1 = require("./woocommerce");
|
|
5
4
|
const env_1 = require("@things-factory/env");
|
|
5
|
+
const woocommerce_1 = require("./woocommerce");
|
|
6
6
|
const woocommerceConfig = env_1.config.get('marketplaceIntegrationWoocommerce', {});
|
|
7
7
|
const { key_id, user_id, consumer_key, consumer_secret } = woocommerceConfig;
|
|
8
8
|
function substitute(path, obj) {
|
|
@@ -29,7 +29,7 @@ const action = async ({ store, method = 'get', path, request }) => {
|
|
|
29
29
|
const { resource = {}, payload = {} } = request;
|
|
30
30
|
path = substitute(path, resource);
|
|
31
31
|
var response = await client[method](path, payload);
|
|
32
|
-
if (response.
|
|
32
|
+
if (response.code) {
|
|
33
33
|
throw response;
|
|
34
34
|
}
|
|
35
35
|
return response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/woocommerce/platform-action.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAE3C,
|
|
1
|
+
{"version":3,"file":"platform-action.js","sourceRoot":"","sources":["../../../server/controllers/woocommerce/platform-action.ts"],"names":[],"mappings":";;;AAAA,6CAA4C;AAE5C,+CAA2C;AAE3C,MAAM,iBAAiB,GAAG,YAAM,CAAC,GAAG,CAAC,mCAAmC,EAAE,EAAE,CAAC,CAAA;AAC7E,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,GAAG,iBAAiB,CAAA;AAE5E,SAAS,UAAU,CAAC,IAAI,EAAE,GAAG;IAC3B,IAAI,KAAK,GAAG,EAAE,CAAA;IACd,IAAI,EAAE,GAAG,YAAY,CAAA;IACrB,IAAI,IAAI,C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class Woocommerce {
|
|
|
30
30
|
return result;
|
|
31
31
|
}
|
|
32
32
|
async post(path, data = {}) {
|
|
33
|
-
const { storeURL } = this.config;
|
|
33
|
+
const { consumer_key, consumer_secret, storeURL } = this.config;
|
|
34
34
|
debug('data', data);
|
|
35
35
|
const jsondata = JSON.stringify(data);
|
|
36
|
-
const endpoint = `${storeURL}/wp-json/wc/v3${path}`;
|
|
36
|
+
const endpoint = `${storeURL}/wp-json/wc/v3${path}?consumer_key=${consumer_key}&consumer_secret=${consumer_secret}`;
|
|
37
37
|
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
38
38
|
method: 'post',
|
|
39
39
|
headers: {
|
|
@@ -46,10 +46,10 @@ class Woocommerce {
|
|
|
46
46
|
return result;
|
|
47
47
|
}
|
|
48
48
|
async put(path, data = {}) {
|
|
49
|
-
const { storeURL } = this.config;
|
|
49
|
+
const { consumer_key, consumer_secret, storeURL } = this.config;
|
|
50
50
|
debug('data', data);
|
|
51
51
|
const jsondata = JSON.stringify(data);
|
|
52
|
-
const endpoint = `${storeURL}/wp-json/wc/v3${path}`;
|
|
52
|
+
const endpoint = `${storeURL}/wp-json/wc/v3${path}?consumer_key=${consumer_key}&consumer_secret=${consumer_secret}`;
|
|
53
53
|
const response = await (0, node_fetch_1.default)(endpoint, {
|
|
54
54
|
method: 'put',
|
|
55
55
|
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,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,IAAS;QAC/B,MAAM,EAAE,YAAY,EAAE,eAAe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EAAE,MAAM,CAAC,CAAA;QAEhC,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAnFD,kCAmFC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/integration-marketplace",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.52",
|
|
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.6.
|
|
29
|
-
"@things-factory/auth-ui": "^3.6.
|
|
30
|
-
"@things-factory/biz-base": "^3.6.
|
|
31
|
-
"@things-factory/code-ui": "^3.6.
|
|
32
|
-
"@things-factory/context-ui": "^3.6.
|
|
33
|
-
"@things-factory/grist-ui": "^3.6.
|
|
34
|
-
"@things-factory/i18n-ui": "^3.6.
|
|
35
|
-
"@things-factory/integration-lmd": "^3.6.
|
|
36
|
-
"@things-factory/integration-ui": "^3.6.
|
|
37
|
-
"@things-factory/more-ui": "^3.6.
|
|
38
|
-
"@things-factory/resource-ui": "^3.6.
|
|
39
|
-
"@things-factory/setting-ui": "^3.6.
|
|
40
|
-
"@things-factory/system-ui": "^3.6.
|
|
28
|
+
"@things-factory/apptool-ui": "^3.6.52",
|
|
29
|
+
"@things-factory/auth-ui": "^3.6.52",
|
|
30
|
+
"@things-factory/biz-base": "^3.6.52",
|
|
31
|
+
"@things-factory/code-ui": "^3.6.52",
|
|
32
|
+
"@things-factory/context-ui": "^3.6.52",
|
|
33
|
+
"@things-factory/grist-ui": "^3.6.52",
|
|
34
|
+
"@things-factory/i18n-ui": "^3.6.52",
|
|
35
|
+
"@things-factory/integration-lmd": "^3.6.52",
|
|
36
|
+
"@things-factory/integration-ui": "^3.6.52",
|
|
37
|
+
"@things-factory/more-ui": "^3.6.52",
|
|
38
|
+
"@things-factory/resource-ui": "^3.6.52",
|
|
39
|
+
"@things-factory/setting-ui": "^3.6.52",
|
|
40
|
+
"@things-factory/system-ui": "^3.6.52",
|
|
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": "bc26afe1527faaf050d43122b8cf4248769b814e"
|
|
57
57
|
}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
export function createOrderNote(req) {
|
|
5
5
|
return {
|
|
6
6
|
method: 'post',
|
|
7
|
-
path: '/orders/{orderId}
|
|
7
|
+
path: '/orders/{orderId}/notes',
|
|
8
8
|
denormalize(req) {
|
|
9
|
-
var { note } = req || {}
|
|
9
|
+
var { note, orderId } = req || {}
|
|
10
10
|
|
|
11
|
-
return { resource: { orderId:
|
|
11
|
+
return { resource: { orderId: orderId }, payload: { note, customer_note: true } }
|
|
12
12
|
},
|
|
13
13
|
normalize(res) {
|
|
14
14
|
return res.items
|
|
@@ -26,7 +26,7 @@ export function getStoreOrders() {
|
|
|
26
26
|
},
|
|
27
27
|
async normalize(res, { store }) {
|
|
28
28
|
// return res.orders
|
|
29
|
-
var { items: orders, totalItems
|
|
29
|
+
var { items: orders, totalItems } = res
|
|
30
30
|
let results: any[] = []
|
|
31
31
|
|
|
32
32
|
for (var i = 0; i < orders.length; i++) {
|
|
@@ -34,7 +34,7 @@ export function getStoreOrders() {
|
|
|
34
34
|
|
|
35
35
|
const {
|
|
36
36
|
id: name,
|
|
37
|
-
|
|
37
|
+
number: orderNo,
|
|
38
38
|
currency,
|
|
39
39
|
total: totalAmount,
|
|
40
40
|
payment_method: paymentMethod,
|
|
@@ -43,6 +43,7 @@ export function getStoreOrders() {
|
|
|
43
43
|
date_created_gmt,
|
|
44
44
|
date_modified_gmt,
|
|
45
45
|
shipping,
|
|
46
|
+
billing,
|
|
46
47
|
line_items
|
|
47
48
|
} = order
|
|
48
49
|
|
|
@@ -65,21 +66,57 @@ export function getStoreOrders() {
|
|
|
65
66
|
}
|
|
66
67
|
})
|
|
67
68
|
|
|
68
|
-
const {
|
|
69
|
+
const {
|
|
70
|
+
address_1: shippingAddress1,
|
|
71
|
+
address_2: shippingAddress2,
|
|
72
|
+
postcode: shippingPostCode,
|
|
73
|
+
country: shippingCountry,
|
|
74
|
+
city: shippingCity,
|
|
75
|
+
first_name: shippingFirstName,
|
|
76
|
+
last_name: shippingLastName,
|
|
77
|
+
state: shippingState,
|
|
78
|
+
phone: shippingPhone,
|
|
79
|
+
email: shippingEmail
|
|
80
|
+
} = shipping
|
|
81
|
+
|
|
82
|
+
const {
|
|
83
|
+
address_1: billingAddress1,
|
|
84
|
+
address_2: billingAddress2,
|
|
85
|
+
postcode: billingPostCode,
|
|
86
|
+
country: billingCountry,
|
|
87
|
+
city: billingCity,
|
|
88
|
+
first_name: billingFirstName,
|
|
89
|
+
last_name: billingLastName,
|
|
90
|
+
state: billingState,
|
|
91
|
+
phone: billingPhone,
|
|
92
|
+
email: billingEmail
|
|
93
|
+
} = billing
|
|
69
94
|
|
|
70
95
|
var orderShipping = {
|
|
71
|
-
address1:
|
|
72
|
-
address2:
|
|
96
|
+
address1: shippingAddress1 == null ? billingAddress1 : shippingAddress1,
|
|
97
|
+
address2: shippingAddress2 == null ? billingAddress2 : shippingAddress2,
|
|
73
98
|
address3: null,
|
|
74
99
|
address4: null,
|
|
75
100
|
address5: null,
|
|
76
|
-
phone1: null,
|
|
101
|
+
phone1: shippingPhone == null || shippingPhone == '' ? billingPhone : shippingPhone,
|
|
77
102
|
phone2: null,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
103
|
+
email: shippingEmail == null ? billingEmail : shippingEmail,
|
|
104
|
+
postCode: shippingPostCode == null ? billingPostCode : shippingPostCode,
|
|
105
|
+
city: shippingCity == null ? billingCity : shippingCity,
|
|
106
|
+
state: shippingState == null ? billingState : shippingState,
|
|
107
|
+
country:
|
|
108
|
+
shippingCountry == null
|
|
109
|
+
? billingCountry === 'MY'
|
|
110
|
+
? 'Malaysia'
|
|
111
|
+
: billingCountry
|
|
112
|
+
: billingCountry === 'MY'
|
|
113
|
+
? 'Malaysia'
|
|
114
|
+
: billingCountry,
|
|
81
115
|
collectionCurrency: currency,
|
|
82
|
-
attentionTo:
|
|
116
|
+
attentionTo:
|
|
117
|
+
shippingFirstName == null
|
|
118
|
+
? `${billingFirstName} ${billingLastName}`
|
|
119
|
+
: `${shippingFirstName} ${shippingLastName}`
|
|
83
120
|
}
|
|
84
121
|
|
|
85
122
|
results.push({
|
|
@@ -89,7 +126,7 @@ export function getStoreOrders() {
|
|
|
89
126
|
orderCreatedAt,
|
|
90
127
|
orderUpdatedAt,
|
|
91
128
|
totalAmount,
|
|
92
|
-
itemCount,
|
|
129
|
+
itemCount: line_items.length,
|
|
93
130
|
orderItems,
|
|
94
131
|
orderShipping
|
|
95
132
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { config } from '@things-factory/env'
|
|
2
|
+
|
|
1
3
|
import { Woocommerce } from './woocommerce'
|
|
2
4
|
|
|
3
|
-
import { config } from '@things-factory/env'
|
|
4
5
|
const woocommerceConfig = config.get('marketplaceIntegrationWoocommerce', {})
|
|
5
6
|
const { key_id, user_id, consumer_key, consumer_secret } = woocommerceConfig
|
|
6
7
|
|
|
@@ -35,7 +36,7 @@ export const action = async ({ store, method = 'get', path, request }) => {
|
|
|
35
36
|
path = substitute(path, resource)
|
|
36
37
|
|
|
37
38
|
var response = await client[method](path, payload)
|
|
38
|
-
if (response.
|
|
39
|
+
if (response.code) {
|
|
39
40
|
throw response
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -48,13 +48,13 @@ export class Woocommerce {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
async post(path: string, data: any = {}) {
|
|
51
|
-
const { storeURL } = this.config
|
|
51
|
+
const { consumer_key, consumer_secret, storeURL } = this.config
|
|
52
52
|
|
|
53
53
|
debug('data', data)
|
|
54
54
|
|
|
55
55
|
const jsondata = JSON.stringify(data)
|
|
56
56
|
|
|
57
|
-
const endpoint = `${storeURL}/wp-json/wc/v3${path}`
|
|
57
|
+
const endpoint = `${storeURL}/wp-json/wc/v3${path}?consumer_key=${consumer_key}&consumer_secret=${consumer_secret}`
|
|
58
58
|
|
|
59
59
|
const response = await fetch(endpoint, {
|
|
60
60
|
method: 'post',
|
|
@@ -71,13 +71,13 @@ export class Woocommerce {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
async put(path: string, data: any = {}) {
|
|
74
|
-
const { storeURL } = this.config
|
|
74
|
+
const { consumer_key, consumer_secret, storeURL } = this.config
|
|
75
75
|
|
|
76
76
|
debug('data', data)
|
|
77
77
|
|
|
78
78
|
const jsondata = JSON.stringify(data)
|
|
79
79
|
|
|
80
|
-
const endpoint = `${storeURL}/wp-json/wc/v3${path}`
|
|
80
|
+
const endpoint = `${storeURL}/wp-json/wc/v3${path}?consumer_key=${consumer_key}&consumer_secret=${consumer_secret}`
|
|
81
81
|
|
|
82
82
|
const response = await fetch(endpoint, {
|
|
83
83
|
method: 'put',
|