-
Notifications
You must be signed in to change notification settings - Fork 5.3k
/
Copy pathnew-product-created.mjs
44 lines (43 loc) · 1.05 KB
/
new-product-created.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import common from "../common/common.mjs";
import constants from "../../common/constants.mjs";
export default {
...common,
key: "wix_api_key-new-product-created",
name: "New Product Created",
description: "Emit new event when a new product is created. [See the documentation](https://dev.wix.com/api/rest/wix-stores/catalog/products/query-products)",
version: "0.0.2",
type: "source",
methods: {
...common.methods,
getParams() {
return {
query: {
paging: {
limit: constants.DEFAULT_LIMIT,
offset: 0,
},
},
};
},
async getResources({
siteId, params,
}) {
const { products } = await this.wix.listProducts({
siteId,
data: params,
});
return products;
},
advancePage(params) {
params.query.paging.offset += constants.DEFAULT_LIMIT;
return params;
},
generateMeta(product) {
return {
id: product.id,
summary: product.name,
ts: this.getTs(product),
};
},
},
};