Skip to content

Commit 7cfa2ac

Browse files
committed
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.
1 parent d3e3821 commit 7cfa2ac

File tree

32 files changed

+3810
-7
lines changed

32 files changed

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

0 commit comments

Comments
 (0)