Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/woocommerce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/woocommerce",
"version": "0.0.1",
"version": "0.0.2",
"description": "Pipedream WooCommerce Components",
"main": "woocommerce.app.mjs",
"keywords": [
Expand All @@ -16,7 +16,7 @@
"crypto": "^1.0.1",
"lodash.pick": "^4.4.0",
"lodash.pickby": "^4.6.0",
"querystring": "^0.2.1"
"query-string": "^7.1.1"
},
"gitHead": "e12480b94cc03bed4808ebc6b13e7fdb3a1ba535",
"publishConfig": {
Expand Down
12 changes: 12 additions & 0 deletions components/woocommerce/sources/common/base.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export default {
},
},
hooks: {
async deploy() {
const events = await this.getSampleEvents({
perPage: 25,
});
for (const event of events) {
const meta = this.generateMeta("", event);
this.$emit(event, meta);
}
},
async activate() {
const hookIds = [];
for (const topicType of this.topics) {
Expand Down Expand Up @@ -47,6 +56,9 @@ export default {
.digest("base64");
return signatureComputed === signature;
},
getSampleEvents() {
throw new Error("getSampleEvents is not implemented");
},
},
async run(event) {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import common from "../common/base.mjs";
export default {
...common,
key: "woocommerce-new-coupon-event",
name: "New CouponEvent",
name: "New Coupon Event (Instant)",
description: "Emit new event each time the specified coupon event(s) occur",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
async getSampleEvents({ perPage }) {
return this.woocommerce.listCoupons({
per_page: perPage,
orderby: "date",
});
},
getTopic(topicType) {
return `coupon.${topicType}`;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import common from "../common/base.mjs";
export default {
...common,
key: "woocommerce-new-customer-event",
name: "New Customer Event",
name: "New Customer Event (Instant)",
description: "Emit new event each time the specified customer event(s) occur",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
async getSampleEvents({ perPage }) {
return this.woocommerce.listCustomers({
per_page: perPage,
orderby: "registered_date",
});
},
getTopic(topicType) {
return `customer.${topicType}`;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import common from "../common/base.mjs";
export default {
...common,
key: "woocommerce-new-order-event",
name: "New Order Event",
name: "New Order Event (Instant)",
description: "Emit new event each time the specified order event(s) occur",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
async getSampleEvents({ perPage }) {
return this.woocommerce.listOrders({
per_page: perPage,
orderby: "date",
});
},
getTopic(topicType) {
return `order.${topicType}`;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ import common from "../common/base.mjs";
export default {
...common,
key: "woocommerce-new-product-event",
name: "New Product Event",
name: "New Product Event (Instant)",
description: "Emit new event each time the specified product event(s) occur",
version: "0.0.2",
version: "0.0.3",
type: "source",
dedupe: "unique",
methods: {
...common.methods,
async getSampleEvents({ perPage }) {
return this.woocommerce.listProducts({
per_page: perPage,
orderby: "date",
});
},
getTopic(topicType) {
return `product.${topicType}`;
},
Expand Down
23 changes: 17 additions & 6 deletions components/woocommerce/woocommerce.app.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import WooCommerceRestApi from "@woocommerce/woocommerce-rest-api";
import querystring from "querystring";
import querystring from "query-string";
import constants from "./constants.mjs";

export default {
Expand Down Expand Up @@ -128,7 +128,9 @@ export default {
label: "Products",
description: "Products to add to the the new order",
async options({ page }) {
const products = await this.listProducts(page + 1);
const products = await this.listProducts({
page: page + 1,
});
return products.map((product) => ({
label: product.name,
value: product.id,
Expand Down Expand Up @@ -186,9 +188,9 @@ export default {
return this.postResource("webhooks", data);
},
async deleteWebhook(id) {
return this.deleteResource(`webhooks/${id}`);
return this.deleteResource(`webhooks/${id}?force=true`);
},
async listCustomers(params) {
async listCustomers(params = null) {
const q = querystring.stringify(params);
return this.listResources(`customers?${q}`);
},
Expand All @@ -198,15 +200,24 @@ export default {
async listPaymentGateways() {
return this.listResources("payment_gateways");
},
async listProducts(page) {
return this.listResources(`products?page=${page}`);
async listProducts(params = null) {
const q = querystring.stringify(params);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess querystring is deprecated. Would you mind using query-string or something similar?

return this.listResources(`products?${q}`);
},
async listCoupons(params = null) {
const q = querystring.stringify(params);
return this.listResources(`coupons?${q}`);
},
async listCategories(page) {
return this.listResources(`products/categories?page=${page}`);
},
async getOrder(id) {
return this.listResources(`orders/${id}`);
},
async listOrders(params = null) {
const q = querystring.stringify(params);
return this.listResources(`orders?${q}`);
},
async createOrder(data) {
return this.postResource("orders", data);
},
Expand Down
14 changes: 7 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.