Skip to content

Commit a22c5cf

Browse files
committed
Update Lightspeed eCom C-Series sources to enhance webhook handling and metadata generation
- Updated webhook address to include '/webhook' for proper endpoint configuration. - Modified `run` method to accept headers for improved metadata generation. - Simplified summary generation in multiple sources to remove unnecessary method calls. - Adjusted `generateMeta` in `product-deleted` to utilize headers for product ID and current timestamp.
1 parent 5126e8e commit a22c5cf

File tree

11 files changed

+18
-16
lines changed

11 files changed

+18
-16
lines changed

components/lightspeed_ecom_c_series/sources/common/base.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default {
2626
itemGroup: this.getItemGroup(),
2727
itemAction: this.getItemAction(),
2828
format: "json",
29-
address: this.http.endpoint,
29+
address: `${this.http.endpoint}/webhook`,
3030
},
3131
},
3232
});
@@ -37,11 +37,13 @@ export default {
3737
await this.app.deleteHook(webhookId);
3838
},
3939
},
40-
async run({ body }) {
40+
async run({
41+
body, headers,
42+
}) {
4143
this.http.respond({
4244
status: 200,
4345
});
4446

45-
this.$emit(body, this.generateMeta(body));
47+
this.$emit(body, this.generateMeta(body, headers));
4648
},
4749
};

components/lightspeed_ecom_c_series/sources/customer-updated/customer-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.customer.id,
23-
summary: this.getSummary(`Customer with ID ${body.customer.id} updated`),
23+
summary: `Customer with ID ${body.customer.id} updated`,
2424
ts: Date.parse(body.customer.updatedAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/invoice-updated/invoice-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.invoice.id,
23-
summary: this.getSummary(`Invoice with ID ${body.invoice.id} updated`),
23+
summary: `Invoice with ID ${body.invoice.id} updated`,
2424
ts: Date.parse(body.invoice.updatedAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/new-customer-created/new-customer-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.customer.id,
23-
summary: this.getSummary(`Customer with ID ${body.customer.id} created`),
23+
summary: `Customer with ID ${body.customer.id} created`,
2424
ts: Date.parse(body.customer.createdAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/new-invoice-created/new-invoice-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.invoice.id,
23-
summary: this.getSummary(`Invoice with ID ${body.invoice.id} created`),
23+
summary: `Invoice with ID ${body.invoice.id} created`,
2424
ts: Date.parse(body.invoice.createdAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/new-order-created/new-order-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.order.id,
23-
summary: this.getSummary(`Order with ID ${body.order.id} created`),
23+
summary: `Order with ID ${body.order.id} created`,
2424
ts: Date.parse(body.order.createdAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/new-product-created/new-product-created.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.product.id,
23-
summary: this.getSummary(`Product with ID ${body.product.id} created`),
23+
summary: `Product with ID ${body.product.id} created`,
2424
ts: Date.parse(body.product.createdAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/order-shipped/order-shipped.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.order.id,
23-
summary: this.getSummary(`Order with ID ${body.order.id} shipped`),
23+
summary: `Order with ID ${body.order.id} shipped`,
2424
ts: Date.parse(body.order.updatedAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/order-updated/order-updated.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default {
2020
generateMeta(body) {
2121
return {
2222
id: body.order.id,
23-
summary: this.getSummary(`Order with ID ${body.order.id} updated`),
23+
summary: `Order with ID ${body.order.id} updated`,
2424
ts: Date.parse(body.order.updatedAt),
2525
};
2626
},

components/lightspeed_ecom_c_series/sources/product-deleted/product-deleted.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ export default {
1717
getItemAction() {
1818
return "deleted";
1919
},
20-
generateMeta(body) {
20+
generateMeta(body, headers) {
2121
return {
22-
id: body.product.id,
23-
summary: this.getSummary(`Product with ID ${body.product.id} deleted`),
24-
ts: Date.parse(body.product.deletedAt),
22+
id: headers["x-product-id"],
23+
summary: `Product with ID ${headers["x-product-id"]} deleted`,
24+
ts: Date.now(),
2525
};
2626
},
2727
},

0 commit comments

Comments
 (0)