Skip to content

Commit 140cab6

Browse files
committed
Get and List Order
1 parent c31961c commit 140cab6

File tree

6 files changed

+48
-63
lines changed

6 files changed

+48
-63
lines changed

components/webflow/actions/get-order/get-order.mjs

Lines changed: 0 additions & 34 deletions
This file was deleted.

components/webflow/common/constants.mjs

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import app from "../../webflow_v2.app.mjs";
2+
3+
export default {
4+
key: "webflow_v2-get-order",
5+
name: "Get Order",
6+
description: "Get info on an order. [See the docs here](https://developers.webflow.com/#get-order)",
7+
version: "0.0.{{ts}}",
8+
type: "action",
9+
props: {
10+
app,
11+
siteId: {
12+
propDefinition: [
13+
app,
14+
"sites",
15+
],
16+
},
17+
orderId: {
18+
propDefinition: [
19+
app,
20+
"orders",
21+
],
22+
},
23+
},
24+
async run({ $ }) {
25+
const response = await this.app.getOrder(this.siteId, this.orderId);
26+
27+
$.export("$summary", "Successfully retrieved order");
28+
29+
return response;
30+
},
31+
};

components/webflow/actions/list-orders/list-orders.mjs renamed to components/webflow_v2/actions/list-orders/list-orders.mjs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
1-
import webflow from "../../webflow.app.mjs";
1+
import app from "../../webflow.app.mjs";
22
import constants from "../common/constants.mjs";
33

44
export default {
5-
key: "webflow-list-orders",
5+
key: "webflow_v2-list-orders",
66
name: "List Orders",
77
description: "List orders. [See the docs here](https://developers.webflow.com/#get-all-orders)",
8-
version: "0.0.4",
8+
version: "0.0.{{ts}}",
99
type: "action",
1010
props: {
11-
webflow,
11+
app,
1212
siteId: {
1313
propDefinition: [
14-
webflow,
14+
app,
1515
"sites",
1616
],
1717
},
1818
status: {
1919
label: "Status",
20-
description: "The status to filter the orders.",
20+
description: "If specified, only orders with this status will be listed.",
2121
type: "string",
2222
options: constants.ORDER_STATUSES,
2323
optional: true,
2424
},
2525
},
2626
async run({ $ }) {
27-
const response = await this.webflow.getOrders({
28-
siteId: this.siteId,
29-
status: this.status,
30-
});
27+
const { app, ...data } = this;
28+
const response = await app.listOrders(data);
3129

32-
$.export("$summary", "Successfully retrieved orders");
30+
$.export("$summary", `Successfully retrieved ${response?.length} orders`);
3331

3432
return response;
3533
},

components/webflow_v2/webflow_v2.app.mjs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,17 @@ export default {
9898
webhookId,
9999
});
100100
},
101-
async getOrder({
102-
siteId, orderId,
103-
}) {
104-
const apiClient = this._createApiClient();
105-
106-
return apiClient.get(`/sites/${siteId}/order/${orderId}`);
101+
async getOrder(siteId, orderId) {
102+
return this.webflowClient().orders.get(siteId, orderId);
107103
},
108104
async listOrders({
109-
page, siteId, status,
105+
page: offset = 0, siteId, status,
110106
}) {
111-
const apiClient = this._createApiClient();
112-
113-
return apiClient.get(`/sites/${siteId}/orders`, {
114-
status: status,
115-
offset: page ?? 0,
116-
limit: constants.LIMIT,
107+
const response = await this.webflowClient().orders.list(siteId, {
108+
offset,
109+
status
117110
});
111+
return response?.orders;
118112
},
119113
async listDomains(siteId) {
120114
const response = await this.webflowClient().sites.getCustomDomain(siteId);
@@ -168,6 +162,6 @@ export default {
168162
return this.webflowClient().sites.publish(siteId, {
169163
customDomains
170164
})
171-
}
165+
},
172166
},
173167
};

0 commit comments

Comments
 (0)