@things-factory/integration-marketplace 5.0.0-alpha.4 → 5.0.0-alpha.40
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/client/pages/marketplace-stores.js +8 -0
- package/dist-server/controllers/index.js +1 -0
- package/dist-server/controllers/index.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-order.js +20 -0
- package/dist-server/controllers/magento/apis/get-store-order.js.map +1 -0
- package/dist-server/controllers/magento/apis/get-store-orders.js +34 -4
- package/dist-server/controllers/magento/apis/get-store-orders.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-product-categories.js +47 -0
- package/dist-server/controllers/magento/apis/get-store-product-categories.js.map +1 -0
- package/dist-server/controllers/magento/apis/get-store-products.js +29 -11
- package/dist-server/controllers/magento/apis/get-store-products.js.map +1 -1
- package/dist-server/controllers/magento/apis/get-store-stock-item.js +1 -1
- package/dist-server/controllers/magento/apis/get-store-stock-item.js.map +1 -1
- package/dist-server/controllers/magento/apis/index.js +5 -0
- package/dist-server/controllers/magento/apis/index.js.map +1 -1
- package/dist-server/controllers/magento/apis/update-order-status.js +82 -0
- package/dist-server/controllers/magento/apis/update-order-status.js.map +1 -0
- package/dist-server/controllers/magento/apis/update-store-product-price.js +28 -0
- package/dist-server/controllers/magento/apis/update-store-product-price.js.map +1 -0
- package/dist-server/controllers/magento/apis/update-store-product-stock.js +1 -1
- package/dist-server/controllers/magento/apis/update-store-product-stock.js.map +1 -1
- package/dist-server/controllers/magento/apis/update-store-product-variation-price.js +28 -0
- package/dist-server/controllers/magento/apis/update-store-product-variation-price.js.map +1 -0
- package/dist-server/controllers/magento/apis/update-store-product-variation-stock.js +1 -1
- package/dist-server/controllers/magento/apis/update-store-product-variation-stock.js.map +1 -1
- package/dist-server/controllers/magento/magento.js +4 -4
- package/dist-server/controllers/magento/magento.js.map +1 -1
- package/dist-server/controllers/magento/platform-action.js +1 -0
- package/dist-server/controllers/magento/platform-action.js.map +1 -1
- package/dist-server/controllers/shopee/apis/get-store-order.js +8 -2
- package/dist-server/controllers/shopee/apis/get-store-order.js.map +1 -1
- package/dist-server/controllers/shopify/apis/get-store-orders.js +2 -2
- package/dist-server/controllers/shopify/apis/get-store-orders.js.map +1 -1
- package/dist-server/controllers/shopify/apis/set-store-order-status-ready-to-ship.js +3 -2
- package/dist-server/controllers/shopify/apis/set-store-order-status-ready-to-ship.js.map +1 -1
- package/dist-server/controllers/store-api/index.js +21 -0
- package/dist-server/controllers/store-api/index.js.map +1 -1
- package/dist-server/controllers/tiktok/apis/echo.js +19 -0
- package/dist-server/controllers/tiktok/apis/echo.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-order-document.js +27 -0
- package/dist-server/controllers/tiktok/apis/get-store-order-document.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-order-package.js +47 -0
- package/dist-server/controllers/tiktok/apis/get-store-order-package.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-order-packages.js +39 -0
- package/dist-server/controllers/tiktok/apis/get-store-order-packages.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-order.js +138 -0
- package/dist-server/controllers/tiktok/apis/get-store-order.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-orders.js +48 -0
- package/dist-server/controllers/tiktok/apis/get-store-orders.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-attributes.js +30 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-attributes.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-categories.js +28 -0
- package/dist-server/controllers/tiktok/apis/get-store-product-categories.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-product.js +91 -0
- package/dist-server/controllers/tiktok/apis/get-store-product.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/get-store-products.js +36 -0
- package/dist-server/controllers/tiktok/apis/get-store-products.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/index.js +30 -0
- package/dist-server/controllers/tiktok/apis/index.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/update-order-status.js +28 -0
- package/dist-server/controllers/tiktok/apis/update-order-status.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-price.js +28 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-price.js.map +1 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-stock.js +32 -0
- package/dist-server/controllers/tiktok/apis/update-store-product-variation-stock.js.map +1 -0
- package/dist-server/controllers/tiktok/client/index.js +19 -0
- package/dist-server/controllers/tiktok/client/index.js.map +1 -0
- package/dist-server/controllers/tiktok/client/signature.js +63 -0
- package/dist-server/controllers/tiktok/client/signature.js.map +1 -0
- package/dist-server/controllers/tiktok/client/tiktok.js +113 -0
- package/dist-server/controllers/tiktok/client/tiktok.js.map +1 -0
- package/dist-server/controllers/tiktok/client/types.js +3 -0
- package/dist-server/controllers/tiktok/client/types.js.map +1 -0
- package/dist-server/controllers/tiktok/index.js +34 -0
- package/dist-server/controllers/tiktok/index.js.map +1 -0
- package/dist-server/controllers/tiktok/platform-action.js +50 -0
- package/dist-server/controllers/tiktok/platform-action.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/get-customer-info.js +22 -0
- package/dist-server/controllers/woocommerce/apis/get-customer-info.js.map +1 -0
- package/dist-server/controllers/woocommerce/apis/get-store-orders.js +23 -3
- package/dist-server/controllers/woocommerce/apis/get-store-orders.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/get-store-products.js +48 -6
- package/dist-server/controllers/woocommerce/apis/get-store-products.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/index.js +1 -0
- package/dist-server/controllers/woocommerce/apis/index.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/update-order-status.js +17 -15
- package/dist-server/controllers/woocommerce/apis/update-order-status.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/update-product-attribute.js +4 -3
- package/dist-server/controllers/woocommerce/apis/update-product-attribute.js.map +1 -1
- package/dist-server/controllers/woocommerce/apis/update-store-product-variation-price.js +1 -1
- package/dist-server/controllers/woocommerce/apis/update-store-product-variation-price.js.map +1 -1
- package/dist-server/entities/marketplace-store.js +4 -0
- package/dist-server/entities/marketplace-store.js.map +1 -1
- package/dist-server/graphql/types/marketplace-store/marketplace-store-patch.js +1 -0
- package/dist-server/graphql/types/marketplace-store/marketplace-store-patch.js.map +1 -1
- package/dist-server/graphql/types/marketplace-store/marketplace-store.js +1 -0
- package/dist-server/graphql/types/marketplace-store/marketplace-store.js.map +1 -1
- package/dist-server/graphql/types/marketplace-store/new-marketplace-store.js +1 -0
- package/dist-server/graphql/types/marketplace-store/new-marketplace-store.js.map +1 -1
- package/package.json +15 -15
- package/server/controllers/index.ts +1 -0
- package/server/controllers/magento/apis/get-store-order.ts +15 -0
- package/server/controllers/magento/apis/get-store-orders.ts +36 -4
- package/server/controllers/magento/apis/get-store-product-categories.ts +43 -0
- package/server/controllers/magento/apis/get-store-products.ts +35 -11
- package/server/controllers/magento/apis/get-store-stock-item.ts +1 -1
- package/server/controllers/magento/apis/index.ts +5 -0
- package/server/controllers/magento/apis/update-order-status.ts +81 -0
- package/server/controllers/magento/apis/update-store-product-price.ts +24 -0
- package/server/controllers/magento/apis/update-store-product-stock.ts +1 -1
- package/server/controllers/magento/apis/update-store-product-variation-price.ts +24 -0
- package/server/controllers/magento/apis/update-store-product-variation-stock.ts +1 -1
- package/server/controllers/magento/magento.ts +5 -4
- package/server/controllers/magento/platform-action.ts +1 -0
- package/server/controllers/shopee/apis/get-store-order.ts +8 -2
- package/server/controllers/shopify/apis/get-store-orders.ts +2 -2
- package/server/controllers/shopify/apis/set-store-order-status-ready-to-ship.ts +3 -2
- package/server/controllers/store-api/index.ts +9 -0
- package/server/controllers/tiktok/apis/echo.ts +14 -0
- package/server/controllers/tiktok/apis/get-store-order-document.ts +26 -0
- package/server/controllers/tiktok/apis/get-store-order-package.ts +46 -0
- package/server/controllers/tiktok/apis/get-store-order-packages.ts +43 -0
- package/server/controllers/tiktok/apis/get-store-order.ts +171 -0
- package/server/controllers/tiktok/apis/get-store-orders.ts +53 -0
- package/server/controllers/tiktok/apis/get-store-product-attributes.ts +29 -0
- package/server/controllers/tiktok/apis/get-store-product-categories.ts +27 -0
- package/server/controllers/tiktok/apis/get-store-product.ts +95 -0
- package/server/controllers/tiktok/apis/get-store-products.ts +38 -0
- package/server/controllers/tiktok/apis/index.ts +13 -0
- package/server/controllers/tiktok/apis/update-order-status.ts +24 -0
- package/server/controllers/tiktok/apis/update-store-product-variation-price.ts +24 -0
- package/server/controllers/tiktok/apis/update-store-product-variation-stock.ts +28 -0
- package/server/controllers/tiktok/client/index.ts +2 -0
- package/server/controllers/tiktok/client/signature.ts +78 -0
- package/server/controllers/tiktok/client/tiktok.ts +153 -0
- package/server/controllers/tiktok/client/types.ts +20 -0
- package/server/controllers/tiktok/index.ts +8 -0
- package/server/controllers/tiktok/platform-action.ts +54 -0
- package/server/controllers/woocommerce/apis/get-customer-info.ts +18 -0
- package/server/controllers/woocommerce/apis/get-store-orders.ts +35 -3
- package/server/controllers/woocommerce/apis/get-store-products.ts +49 -7
- package/server/controllers/woocommerce/apis/index.ts +1 -0
- package/server/controllers/woocommerce/apis/update-order-status.ts +18 -14
- package/server/controllers/woocommerce/apis/update-product-attribute.ts +6 -3
- package/server/controllers/woocommerce/apis/update-store-product-variation-price.ts +1 -1
- package/server/entities/marketplace-store.ts +3 -0
- package/server/graphql/types/marketplace-store/marketplace-store-patch.ts +1 -0
- package/server/graphql/types/marketplace-store/marketplace-store.ts +1 -0
- package/server/graphql/types/marketplace-store/new-marketplace-store.ts +1 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import fetch from 'node-fetch'
|
|
2
|
+
|
|
3
|
+
import { makePublicRequestParameters } from './signature'
|
|
4
|
+
import { Parameter } from './types'
|
|
5
|
+
|
|
6
|
+
const debug = require('debug')('things-factory:integration-marketplace:tiktok')
|
|
7
|
+
|
|
8
|
+
export type TiktokConfig = {
|
|
9
|
+
appKey: string
|
|
10
|
+
appSecret: string
|
|
11
|
+
accessToken: string
|
|
12
|
+
channelShopId: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class Tiktok {
|
|
16
|
+
private config: TiktokConfig
|
|
17
|
+
|
|
18
|
+
constructor(config: TiktokConfig) {
|
|
19
|
+
this.config = {
|
|
20
|
+
...config
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
getBaseURL() {
|
|
25
|
+
return `https://open-api.tiktokglobalshop.com`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @summary Get Method
|
|
30
|
+
* @description Using v3 API, map the consumer_key, consumer_secret to the endpoint path.
|
|
31
|
+
* X-WP-Total is to get the total items from the response
|
|
32
|
+
*/
|
|
33
|
+
async get(path: string, params: Parameter) {
|
|
34
|
+
const { appKey, appSecret, accessToken, channelShopId } = this.config
|
|
35
|
+
|
|
36
|
+
const qs = Object.entries({
|
|
37
|
+
...params,
|
|
38
|
+
...makePublicRequestParameters(appKey, appSecret, path, accessToken, channelShopId, params)
|
|
39
|
+
})
|
|
40
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
41
|
+
.join('&')
|
|
42
|
+
|
|
43
|
+
const endpoint = `${this.getBaseURL()}${path}?${qs ? qs : ''}`
|
|
44
|
+
debug('endpoint', endpoint)
|
|
45
|
+
|
|
46
|
+
const response = await fetch(endpoint, {
|
|
47
|
+
headers: {
|
|
48
|
+
'Content-Type': 'application/json'
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
var result: any = {}
|
|
53
|
+
const resResult: any = await response.json()
|
|
54
|
+
|
|
55
|
+
debug('response result', resResult)
|
|
56
|
+
|
|
57
|
+
return resResult
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async post(path: string, data: any = {}) {
|
|
61
|
+
const { appKey, appSecret, accessToken, channelShopId } = this.config
|
|
62
|
+
|
|
63
|
+
debug('data', data)
|
|
64
|
+
|
|
65
|
+
const jsondata = JSON.stringify(data)
|
|
66
|
+
|
|
67
|
+
const { app_key, timestamp, access_token, sign, shop_id } = makePublicRequestParameters(
|
|
68
|
+
appKey,
|
|
69
|
+
appSecret,
|
|
70
|
+
path,
|
|
71
|
+
accessToken,
|
|
72
|
+
channelShopId
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
const qs = Object.entries({
|
|
76
|
+
app_key,
|
|
77
|
+
timestamp,
|
|
78
|
+
access_token,
|
|
79
|
+
sign,
|
|
80
|
+
shop_id
|
|
81
|
+
})
|
|
82
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
83
|
+
.join('&')
|
|
84
|
+
|
|
85
|
+
const endpoint = `${this.getBaseURL()}${path}?${qs ? '&' + qs : ''}`
|
|
86
|
+
const response = await fetch(endpoint, {
|
|
87
|
+
method: 'post',
|
|
88
|
+
headers: {
|
|
89
|
+
'Content-Type': 'application/json'
|
|
90
|
+
},
|
|
91
|
+
body: jsondata
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
if (response.ok) {
|
|
95
|
+
const result = await response.json()
|
|
96
|
+
if (result?.code == 0) {
|
|
97
|
+
return result
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error(`(${result.code}) ${result.message}`)
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
const result = await response.json()
|
|
103
|
+
throw new Error(`(${result.code}) ${result.message}`)
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async put(path: string, data: any = {}) {
|
|
108
|
+
const { appKey, appSecret, accessToken, channelShopId } = this.config
|
|
109
|
+
|
|
110
|
+
debug('data', data)
|
|
111
|
+
|
|
112
|
+
const jsondata = JSON.stringify(data)
|
|
113
|
+
|
|
114
|
+
const { app_key, timestamp, access_token, sign, shop_id } = makePublicRequestParameters(
|
|
115
|
+
appKey,
|
|
116
|
+
appSecret,
|
|
117
|
+
path,
|
|
118
|
+
accessToken,
|
|
119
|
+
channelShopId
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
const qs = Object.entries({
|
|
123
|
+
app_key,
|
|
124
|
+
timestamp,
|
|
125
|
+
access_token,
|
|
126
|
+
sign,
|
|
127
|
+
shop_id
|
|
128
|
+
})
|
|
129
|
+
.map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`)
|
|
130
|
+
.join('&')
|
|
131
|
+
|
|
132
|
+
const endpoint = `${this.getBaseURL()}${path}?${qs ? '&' + qs : ''}`
|
|
133
|
+
const response = await fetch(endpoint, {
|
|
134
|
+
method: 'put',
|
|
135
|
+
headers: {
|
|
136
|
+
'Content-Type': 'application/json'
|
|
137
|
+
},
|
|
138
|
+
body: jsondata
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
if (response.ok) {
|
|
142
|
+
const result = await response.json()
|
|
143
|
+
if (result?.code == 0) {
|
|
144
|
+
return result
|
|
145
|
+
} else {
|
|
146
|
+
throw new Error(`(${result.code}) ${result.message}`)
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
const result = await response.json()
|
|
150
|
+
throw new Error(`(${result.code}) ${result.message}`)
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type Parameter = {
|
|
2
|
+
[key: string]: any
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Tiktok Open Platform Public Request Parameters
|
|
7
|
+
* @typedef PublicRequestParameters
|
|
8
|
+
* @property {string} timestamp :mandatory
|
|
9
|
+
* @property {string} app_key :mandatory
|
|
10
|
+
* @property {string} access_token :mandatory
|
|
11
|
+
* @property {string} shop_id :mandatory
|
|
12
|
+
* @property {string} sign :mandatory
|
|
13
|
+
*/
|
|
14
|
+
export interface PublicRequestParameters {
|
|
15
|
+
timestamp: string
|
|
16
|
+
app_key: string
|
|
17
|
+
access_token: string
|
|
18
|
+
sign: string
|
|
19
|
+
shop_id?: string
|
|
20
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Tiktok } from './client/tiktok'
|
|
2
|
+
|
|
3
|
+
function substitute(path, obj) {
|
|
4
|
+
var props = []
|
|
5
|
+
var re = /{([^}]+)}/g
|
|
6
|
+
var text
|
|
7
|
+
|
|
8
|
+
while ((text = re.exec(path))) {
|
|
9
|
+
props.push(text[1])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var result = path
|
|
13
|
+
props.forEach(prop => {
|
|
14
|
+
let value = obj[prop.trim()]
|
|
15
|
+
result = result.replace(`{${prop}}`, value === undefined ? '' : value)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
return result
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @summary Building Path Method and Payload
|
|
23
|
+
* @description After denormalise of data is done,
|
|
24
|
+
* platform API method will be called with its path and payload,
|
|
25
|
+
* this section is to build path and substitution of the resource in url as well as the payload for body request.
|
|
26
|
+
* Every Tiktok API call requires consumer_key, consumer_secret, access_token.
|
|
27
|
+
* consumer_key, consumer_secret, access_token are retrieved from tokencraft
|
|
28
|
+
* to avoid permission error from TikTok.
|
|
29
|
+
*/
|
|
30
|
+
export const action = async ({ store, method = 'get', path, request }) => {
|
|
31
|
+
const client = new Tiktok({
|
|
32
|
+
appKey: store.accessKey || '5p6q6g',
|
|
33
|
+
appSecret: store.accessSecret || 'c30cf452265ab418514bb81fa49fc333aecbf081',
|
|
34
|
+
accessToken: store.accessToken,
|
|
35
|
+
channelShopId: store.channelShopId
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
const { resource = {}, payload = {}, requiredAPICall = true } = request
|
|
39
|
+
|
|
40
|
+
let response: any
|
|
41
|
+
if (requiredAPICall) {
|
|
42
|
+
path = substitute(path, resource)
|
|
43
|
+
|
|
44
|
+
response = await client[method](path, payload)
|
|
45
|
+
} else {
|
|
46
|
+
response = { code: 0, message: 'Success' }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (response.code != 0) {
|
|
50
|
+
throw response
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return response
|
|
54
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#retrieve-a-customer */
|
|
2
|
+
/* /wp-json/wc/v3/customers/<id> */
|
|
3
|
+
|
|
4
|
+
export function getCustomerInfo() {
|
|
5
|
+
return {
|
|
6
|
+
method: 'get',
|
|
7
|
+
path: '/customers/{id}',
|
|
8
|
+
denormalize(req) {
|
|
9
|
+
var { id } = req
|
|
10
|
+
return {
|
|
11
|
+
resource: { id }
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
normalize(res) {
|
|
15
|
+
return res.items
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/* https://woocommerce.github.io/woocommerce-rest-api-docs/?javascript#list-all-orders */
|
|
2
2
|
/* /wp-json/wc/v3/orders */
|
|
3
3
|
|
|
4
|
+
import { StoreAPI } from '../../store-api'
|
|
5
|
+
|
|
4
6
|
export function getStoreOrders() {
|
|
5
7
|
return {
|
|
6
8
|
method: 'get',
|
|
@@ -39,6 +41,17 @@ export function getStoreOrders() {
|
|
|
39
41
|
for (var i = 0; i < orders.length; i++) {
|
|
40
42
|
const order = orders[i]
|
|
41
43
|
|
|
44
|
+
var firstName: any
|
|
45
|
+
var lastName: any
|
|
46
|
+
if (order.customer_id != 0) {
|
|
47
|
+
var customerInfo = await StoreAPI.getCustomerInfo(store, { id: order.customer_id })
|
|
48
|
+
|
|
49
|
+
firstName = customerInfo.first_name
|
|
50
|
+
lastName = customerInfo.last_name
|
|
51
|
+
} else {
|
|
52
|
+
firstName = 'GUEST'
|
|
53
|
+
}
|
|
54
|
+
|
|
42
55
|
const {
|
|
43
56
|
id: name,
|
|
44
57
|
number: orderNo,
|
|
@@ -59,7 +72,17 @@ export function getStoreOrders() {
|
|
|
59
72
|
var orderUpdatedAt = new Date(date_modified_gmt)
|
|
60
73
|
|
|
61
74
|
let orderItems = line_items.map(item => {
|
|
62
|
-
var {
|
|
75
|
+
var {
|
|
76
|
+
id: name,
|
|
77
|
+
product_id,
|
|
78
|
+
variation_id,
|
|
79
|
+
quantity: qty,
|
|
80
|
+
price,
|
|
81
|
+
subtotal,
|
|
82
|
+
subtotal_tax: subtotalTax,
|
|
83
|
+
total,
|
|
84
|
+
total_tax: totalTax
|
|
85
|
+
} = item
|
|
63
86
|
|
|
64
87
|
return {
|
|
65
88
|
name,
|
|
@@ -69,7 +92,11 @@ export function getStoreOrders() {
|
|
|
69
92
|
orderNo,
|
|
70
93
|
docRefNo,
|
|
71
94
|
paymentMethod,
|
|
72
|
-
discountValue
|
|
95
|
+
discountValue,
|
|
96
|
+
subtotal,
|
|
97
|
+
subtotalTax,
|
|
98
|
+
total,
|
|
99
|
+
totalTax
|
|
73
100
|
}
|
|
74
101
|
})
|
|
75
102
|
|
|
@@ -135,7 +162,12 @@ export function getStoreOrders() {
|
|
|
135
162
|
totalAmount,
|
|
136
163
|
itemCount: line_items.length,
|
|
137
164
|
orderItems,
|
|
138
|
-
orderShipping
|
|
165
|
+
orderShipping,
|
|
166
|
+
billing,
|
|
167
|
+
shipping,
|
|
168
|
+
firstName,
|
|
169
|
+
lastName,
|
|
170
|
+
isSOF: true
|
|
139
171
|
})
|
|
140
172
|
}
|
|
141
173
|
|
|
@@ -17,8 +17,6 @@ export function getStoreProducts() {
|
|
|
17
17
|
return { payload }
|
|
18
18
|
},
|
|
19
19
|
async normalize(res, { store }) {
|
|
20
|
-
// return res.products
|
|
21
|
-
|
|
22
20
|
const { items, totalItems: totalProducts } = res
|
|
23
21
|
|
|
24
22
|
let results: any[] = []
|
|
@@ -34,7 +32,21 @@ export function getStoreProducts() {
|
|
|
34
32
|
description: product.description,
|
|
35
33
|
hasVariation: product.variations.length > 0 ? true : false,
|
|
36
34
|
categoryId: product?.categories.length > 0 ? product.categories[0].id : null,
|
|
37
|
-
|
|
35
|
+
images: product.images.map(image => {
|
|
36
|
+
return image.src
|
|
37
|
+
}),
|
|
38
|
+
attributes:
|
|
39
|
+
product?.attributes?.map(attribute => {
|
|
40
|
+
return {
|
|
41
|
+
attributeId: attribute.id,
|
|
42
|
+
name: attribute.name,
|
|
43
|
+
originalValue: attribute.options,
|
|
44
|
+
native_attribute_id: attribute.id,
|
|
45
|
+
attribute_key: attribute.name,
|
|
46
|
+
values: attribute.options
|
|
47
|
+
}
|
|
48
|
+
}) || [],
|
|
49
|
+
isVerified: product.purchasable,
|
|
38
50
|
variations:
|
|
39
51
|
productVariations.length === 0
|
|
40
52
|
? [
|
|
@@ -46,9 +58,24 @@ export function getStoreProducts() {
|
|
|
46
58
|
qty: product.manage_stock === true ? parseFloat(product.stock_quantity) : null,
|
|
47
59
|
primaryUnit: 'N/A',
|
|
48
60
|
primaryUnitValue: product.weight === '' ? null : parseFloat(product.weight),
|
|
49
|
-
costPrice: product.price === '' ? null : parseFloat(product.
|
|
61
|
+
costPrice: product.price === '' ? null : parseFloat(product.regular_price),
|
|
50
62
|
sellPrice: product.sale_price === '' ? null : parseFloat(product.sale_price),
|
|
51
|
-
attributes:
|
|
63
|
+
attributes:
|
|
64
|
+
product?.attributes?.map(attribute => {
|
|
65
|
+
return {
|
|
66
|
+
attributeId: attribute.id,
|
|
67
|
+
name: attribute.name,
|
|
68
|
+
originalValue: attribute.options,
|
|
69
|
+
native_attribute_id: attribute.id,
|
|
70
|
+
attribute_key: attribute.name,
|
|
71
|
+
values: attribute.options
|
|
72
|
+
}
|
|
73
|
+
}) || [],
|
|
74
|
+
isEnabled: product.purchasable,
|
|
75
|
+
length: product.dimensions.length * 10,
|
|
76
|
+
width: product.dimensions.width * 10,
|
|
77
|
+
height: product.dimensions.height * 10,
|
|
78
|
+
weight: product.weight * 1000
|
|
52
79
|
}
|
|
53
80
|
]
|
|
54
81
|
: productVariations.map(variant => {
|
|
@@ -61,9 +88,24 @@ export function getStoreProducts() {
|
|
|
61
88
|
qty: variant.manage_stock === true ? parseFloat(variant.stock_quantity) : null,
|
|
62
89
|
primaryUnit: 'N/A',
|
|
63
90
|
primaryUnitValue: variant.weight === '' ? null : parseFloat(variant.weight),
|
|
64
|
-
costPrice: variant.price === '' ? null : parseFloat(variant.
|
|
91
|
+
costPrice: variant.price === '' ? null : parseFloat(variant.regular_price),
|
|
65
92
|
sellPrice: variant.sale_price === '' ? null : parseFloat(variant.sale_price),
|
|
66
|
-
attributes:
|
|
93
|
+
attributes:
|
|
94
|
+
variant?.attributes?.map(attribute => {
|
|
95
|
+
return {
|
|
96
|
+
attributeId: attribute.id,
|
|
97
|
+
name: attribute.name,
|
|
98
|
+
originalValue: attribute.options,
|
|
99
|
+
native_attribute_id: attribute.id,
|
|
100
|
+
attribute_key: attribute.name,
|
|
101
|
+
values: [attribute.option]
|
|
102
|
+
}
|
|
103
|
+
}) || [],
|
|
104
|
+
isEnabled: variant.purchasable,
|
|
105
|
+
length: variant.dimensions.length * 10,
|
|
106
|
+
width: variant.dimensions.width * 10,
|
|
107
|
+
height: variant.dimensions.height * 10,
|
|
108
|
+
weight: variant.weight * 1000
|
|
67
109
|
}
|
|
68
110
|
})
|
|
69
111
|
}
|
|
@@ -15,4 +15,5 @@ export * from './get-store-order'
|
|
|
15
15
|
export * from './update-store-product-price'
|
|
16
16
|
export * from './update-store-product-variant-stock'
|
|
17
17
|
export * from './update-store-product-variant-price'
|
|
18
|
+
export * from './get-customer-info'
|
|
18
19
|
export * from './set-store-order-status-ready-to-ship'
|
|
@@ -3,6 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
import { StoreAPI } from '../../store-api'
|
|
5
5
|
|
|
6
|
+
const ORDER_STATUS = {
|
|
7
|
+
PAYMENT_PENDING: 'pending',
|
|
8
|
+
PROCESSING: 'processing',
|
|
9
|
+
PACKED: 'processing',
|
|
10
|
+
READY_TO_SHIP: 'processing',
|
|
11
|
+
SHIPPED: 'processing',
|
|
12
|
+
CONFIRMED: 'processing',
|
|
13
|
+
DELIVERED: 'completed',
|
|
14
|
+
CLOSED: 'completed',
|
|
15
|
+
CANCELLED: 'cancelled',
|
|
16
|
+
REFUND_COMPLETE: 'refunded',
|
|
17
|
+
RETURN_COMPLETE: 'refunded',
|
|
18
|
+
REVERSE_SHIPMENT_FAILED: 'failed',
|
|
19
|
+
SHIPMENT_LOST_OR_DAMAGED: 'failed',
|
|
20
|
+
PAYMENT_PENDING_TIMEOUT: 'failed'
|
|
21
|
+
}
|
|
22
|
+
|
|
6
23
|
export function updateOrderStatus(req) {
|
|
7
24
|
return {
|
|
8
25
|
method: 'put',
|
|
@@ -12,20 +29,7 @@ export function updateOrderStatus(req) {
|
|
|
12
29
|
|
|
13
30
|
const order = await StoreAPI.getStoreOrder(store, { orderId })
|
|
14
31
|
|
|
15
|
-
let orderStatus = status
|
|
16
|
-
if (orderStatus == 'PACKED') {
|
|
17
|
-
if (order.status == 'pending') {
|
|
18
|
-
orderStatus = 'on-hold'
|
|
19
|
-
} else {
|
|
20
|
-
orderStatus = order.status
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (orderStatus == 'READY_TO_SHIP') {
|
|
24
|
-
orderStatus = 'completed'
|
|
25
|
-
}
|
|
26
|
-
if (orderStatus == 'CANCELLED') {
|
|
27
|
-
orderStatus = 'cancelled'
|
|
28
|
-
}
|
|
32
|
+
let orderStatus = ORDER_STATUS[`${status}`] || order.status
|
|
29
33
|
|
|
30
34
|
return { resource: { orderId: orderId }, payload: { status: orderStatus } }
|
|
31
35
|
},
|
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
export function updateProductAttribute(req) {
|
|
5
5
|
return {
|
|
6
6
|
method: 'put',
|
|
7
|
-
path: '/products/
|
|
7
|
+
path: '/products/{itemId}/variations/{variantId}',
|
|
8
8
|
denormalize(req) {
|
|
9
|
-
var { name, attributeId } = req || {}
|
|
10
9
|
|
|
11
|
-
|
|
10
|
+
var { productSku, itemId, variant } = req || {}
|
|
11
|
+
|
|
12
|
+
const data = variant.attributes
|
|
13
|
+
|
|
14
|
+
return { resource: { itemId, variantId: variant.native_variant_id }, payload: { attributes: data } }
|
|
12
15
|
},
|
|
13
16
|
normalize(res) {
|
|
14
17
|
return res
|
|
@@ -10,7 +10,7 @@ export function updateStoreProductVariationPrice(req) {
|
|
|
10
10
|
|
|
11
11
|
return {
|
|
12
12
|
resource: { itemId: parseInt(productId), variantId: parseInt(variationId) },
|
|
13
|
-
payload: { regular_price: costPrice?.toString(), sale_price: sellPrice?.toString() }
|
|
13
|
+
payload: { regular_price: costPrice?.toString(), sale_price: sellPrice?.toString(), on_sale: costPrice != sellPrice ? true : false }
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
normalize(res) {
|
|
@@ -80,6 +80,9 @@ export class MarketplaceStore {
|
|
|
80
80
|
@Column({ default: false })
|
|
81
81
|
isOwnTransport: Boolean
|
|
82
82
|
|
|
83
|
+
@Column({ default: false })
|
|
84
|
+
reserveEnabled: Boolean
|
|
85
|
+
|
|
83
86
|
@OneToMany(type => MarketplaceDistributor, marketplaceDistributor => marketplaceDistributor.marketplaceStore)
|
|
84
87
|
marketplaceDistributors: MarketplaceDistributor[]
|
|
85
88
|
|