Skip to content

Commit ba23007

Browse files
authored
17440 lightspeed (#18396)
* Enhance Lightspeed eCom C-Series integration with new actions and event sources - Added actions for finding customers, invoices, orders, products, and shipments. - Introduced event sources for customer creation, updates, invoice updates, order creation, updates, and shipping events. - Updated app properties to include customer and order identifiers for better data retrieval. - Version bump to 0.1.0 and added dependencies for improved functionality. * pnpm update * pnpm update * 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. * Refactor Lightspeed eCom C-Series source keys and descriptions for consistency - Updated source keys to follow the new naming convention: "lightspeed_ecom_c_series-{event}". - Corrected minor grammatical errors in descriptions across multiple sources. * Fix grammatical error in description for New Customer Created source * pnpm update * Add annotations to action components for improved metadata - Added 'annotations' property to multiple action components including find-customers, find-invoice, find-order, find-product, find-shipment, get-order, get-order-products, get-product, and get-shipment. - Each annotation includes 'destructiveHint', 'openWorldHint', and 'readOnlyHint' for better clarity on action behavior.
1 parent 311d74e commit ba23007

File tree

33 files changed

+3869
-19
lines changed

33 files changed

+3869
-19
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import app from "../../lightspeed_ecom_c_series.app.mjs";
2+
3+
export default {
4+
key: "lightspeed_ecom_c_series-find-customers",
5+
name: "Find Customers",
6+
description: "Find a customer by ID. [See the documentation](https://developers.lightspeedhq.com/ecom/endpoints/customer/#get-all-customers)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
app,
16+
customerEmail: {
17+
propDefinition: [
18+
app,
19+
"customerEmail",
20+
],
21+
description: "Retrieve all customers from a specific customer based on the customer email",
22+
optional: true,
23+
},
24+
sinceId: {
25+
type: "string",
26+
label: "Since ID",
27+
description: "Restrict results to after the specified ID",
28+
optional: true,
29+
},
30+
createdAtMin: {
31+
propDefinition: [
32+
app,
33+
"createdAtMin",
34+
],
35+
description: "Show customers created after date. **Format: `YYYY-MM-DD HH:MM:SS`**",
36+
},
37+
createdAtMax: {
38+
propDefinition: [
39+
app,
40+
"createdAtMax",
41+
],
42+
description: "Show customers created before date. **Format: `YYYY-MM-DD HH:MM:SS`**",
43+
},
44+
updatedAtMin: {
45+
propDefinition: [
46+
app,
47+
"updatedAtMin",
48+
],
49+
description: "Show customers last updated after date. **Format: `YYYY-MM-DD HH:MM:SS`**",
50+
},
51+
updatedAtMax: {
52+
propDefinition: [
53+
app,
54+
"updatedAtMax",
55+
],
56+
description: "Show customers last updated before date. **Format: `YYYY-MM-DD HH:MM:SS`**",
57+
},
58+
},
59+
async run({ $ }) {
60+
const response = this.app.paginate({
61+
fn: this.app.listCustomers,
62+
$,
63+
params: {
64+
email: this.customerEmail,
65+
since_id: this.sinceId,
66+
created_at_min: this.createdAtMin,
67+
created_at_max: this.createdAtMax,
68+
updated_at_min: this.updatedAtMin,
69+
updated_at_max: this.updatedAtMax,
70+
},
71+
dataField: "customers",
72+
});
73+
74+
const customers = [];
75+
for await (const customer of response) {
76+
customers.push(customer);
77+
}
78+
79+
$.export("$summary", `Successfully found ${customers.length} customer${customers.length === 1
80+
? ""
81+
: "s"}`);
82+
return customers;
83+
},
84+
};
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
import app from "../../lightspeed_ecom_c_series.app.mjs";
2+
3+
export default {
4+
key: "lightspeed_ecom_c_series-find-invoice",
5+
name: "Find Invoice",
6+
description: "Find an invoice by ID. [See the documentation](https://developers.lightspeedhq.com/ecom/endpoints/invoice/#get-all-invoices)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
app,
16+
customerId: {
17+
propDefinition: [
18+
app,
19+
"customerId",
20+
],
21+
description: "Retrieve all invoices from a specific customer based on the customerid",
22+
optional: true,
23+
},
24+
orderNumber: {
25+
propDefinition: [
26+
app,
27+
"orderNumber",
28+
],
29+
description: "Retrieve an order based on the order number",
30+
optional: true,
31+
},
32+
invoiceNumber: {
33+
propDefinition: [
34+
app,
35+
"invoiceNumber",
36+
],
37+
description: "Retrieve an invoice based on the invoice number",
38+
optional: true,
39+
},
40+
sinceId: {
41+
type: "string",
42+
label: "Since ID",
43+
description: "Restrict results to after the specified ID",
44+
optional: true,
45+
},
46+
createdAtMin: {
47+
propDefinition: [
48+
app,
49+
"createdAtMin",
50+
],
51+
description: "Show invoices created after date. **Format: `YYYY-MM-DD HH:MM:SS`**",
52+
},
53+
createdAtMax: {
54+
propDefinition: [
55+
app,
56+
"createdAtMax",
57+
],
58+
description: "Show invoices created before date. **Format: `YYYY-MM-DD HH:MM:SS`**",
59+
},
60+
updatedAtMin: {
61+
propDefinition: [
62+
app,
63+
"updatedAtMin",
64+
],
65+
description: "Show invoices last updated after date. **Format: `YYYY-MM-DD HH:MM:SS`**",
66+
},
67+
updatedAtMax: {
68+
propDefinition: [
69+
app,
70+
"updatedAtMax",
71+
],
72+
description: "Show invoices last updated before date. **Format: `YYYY-MM-DD HH:MM:SS`**",
73+
},
74+
},
75+
async run({ $ }) {
76+
const response = this.app.paginate({
77+
fn: this.app.listInvoice,
78+
$,
79+
params: {
80+
customer: this.customerId,
81+
number: this.invoiceNumber,
82+
order: this.orderNumber,
83+
since_id: this.sinceId,
84+
created_at_min: this.createdAtMin,
85+
created_at_max: this.createdAtMax,
86+
updated_at_min: this.updatedAtMin,
87+
updated_at_max: this.updatedAtMax,
88+
},
89+
dataField: "invoices",
90+
});
91+
92+
const invoices = [];
93+
for await (const invoice of response) {
94+
invoices.push(invoice);
95+
}
96+
97+
$.export("$summary", `Successfully found ${invoices.length} invoice${invoices.length === 1
98+
? ""
99+
: "s"}`);
100+
return invoices;
101+
},
102+
};
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import app from "../../lightspeed_ecom_c_series.app.mjs";
2+
3+
export default {
4+
key: "lightspeed_ecom_c_series-find-order",
5+
name: "Find Order",
6+
description: "Find an order by ID. [See the documentation](https://developers.lightspeedhq.com/ecom/endpoints/order/#get-all-orders)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
app,
16+
customerId: {
17+
propDefinition: [
18+
app,
19+
"customerId",
20+
],
21+
description: "Retrieve all orders from a specific customer based on the customerid",
22+
optional: true,
23+
},
24+
orderNumber: {
25+
propDefinition: [
26+
app,
27+
"orderNumber",
28+
],
29+
description: "Retrieve an order based on the order number",
30+
optional: true,
31+
},
32+
sinceId: {
33+
type: "string",
34+
label: "Since ID",
35+
description: "Restrict results to after the specified ID",
36+
optional: true,
37+
},
38+
createdAtMin: {
39+
propDefinition: [
40+
app,
41+
"createdAtMin",
42+
],
43+
description: "Show orders created after date. **Format: `YYYY-MM-DD HH:MM:SS`**",
44+
},
45+
createdAtMax: {
46+
propDefinition: [
47+
app,
48+
"createdAtMax",
49+
],
50+
description: "Show orders created before date. **Format: `YYYY-MM-DD HH:MM:SS`**",
51+
},
52+
updatedAtMin: {
53+
propDefinition: [
54+
app,
55+
"updatedAtMin",
56+
],
57+
description: "Show orders last updated after date. **Format: `YYYY-MM-DD HH:MM:SS`**",
58+
},
59+
updatedAtMax: {
60+
propDefinition: [
61+
app,
62+
"updatedAtMax",
63+
],
64+
description: "Show orders last updated before date. **Format: `YYYY-MM-DD HH:MM:SS`**",
65+
},
66+
},
67+
async run({ $ }) {
68+
const response = this.app.paginate({
69+
fn: this.app.listOrder,
70+
$,
71+
params: {
72+
customer: this.customerId,
73+
number: this.orderNumber,
74+
since_id: this.sinceId,
75+
created_at_min: this.createdAtMin,
76+
created_at_max: this.createdAtMax,
77+
updated_at_min: this.updatedAtMin,
78+
updated_at_max: this.updatedAtMax,
79+
},
80+
dataField: "orders",
81+
});
82+
83+
const orders = [];
84+
for await (const order of response) {
85+
orders.push(order);
86+
}
87+
88+
$.export("$summary", `Successfully found ${orders.length} order${orders.length === 1
89+
? ""
90+
: "s"}`);
91+
return orders;
92+
},
93+
};
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import app from "../../lightspeed_ecom_c_series.app.mjs";
2+
3+
export default {
4+
key: "lightspeed_ecom_c_series-find-product",
5+
name: "Find Product",
6+
description: "Find an product by ID. [See the documentation](https://developers.lightspeedhq.com/ecom/endpoints/product/#get-all-products)",
7+
version: "0.0.1",
8+
type: "action",
9+
annotations: {
10+
destructiveHint: false,
11+
openWorldHint: true,
12+
readOnlyHint: false,
13+
},
14+
props: {
15+
app,
16+
brandId: {
17+
propDefinition: [
18+
app,
19+
"brandId",
20+
],
21+
optional: true,
22+
},
23+
sinceId: {
24+
type: "string",
25+
label: "Since ID",
26+
description: "Restrict results to after the specified ID",
27+
optional: true,
28+
},
29+
createdAtMin: {
30+
propDefinition: [
31+
app,
32+
"createdAtMin",
33+
],
34+
},
35+
createdAtMax: {
36+
propDefinition: [
37+
app,
38+
"createdAtMax",
39+
],
40+
},
41+
updatedAtMin: {
42+
propDefinition: [
43+
app,
44+
"updatedAtMin",
45+
],
46+
},
47+
updatedAtMax: {
48+
propDefinition: [
49+
app,
50+
"updatedAtMax",
51+
],
52+
},
53+
},
54+
async run({ $ }) {
55+
const response = this.app.paginate({
56+
fn: this.app.listProduct,
57+
$,
58+
params: {
59+
brand: this.brandId,
60+
since_id: this.sinceId,
61+
created_at_min: this.createdAtMin,
62+
created_at_max: this.createdAtMax,
63+
updated_at_min: this.updatedAtMin,
64+
updated_at_max: this.updatedAtMax,
65+
},
66+
dataField: "products",
67+
});
68+
69+
const products = [];
70+
for await (const product of response) {
71+
products.push(product);
72+
}
73+
74+
$.export("$summary", `Successfully found ${products.length} product${products.length === 1
75+
? ""
76+
: "s"}`);
77+
return products;
78+
},
79+
};

0 commit comments

Comments
 (0)