Skip to content

Commit d4a1acb

Browse files
authored
Merging pull request #18283
1 parent 16fa181 commit d4a1acb

File tree

15 files changed

+1299
-155
lines changed

15 files changed

+1299
-155
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import app from "../../billbee.app.mjs";
2+
3+
export default {
4+
key: "billbee-add-shipment-to-order",
5+
name: "Add Shipment To Order",
6+
description: "Add a shipment to an existing order. [See the documentation](https://app.billbee.io//swagger/ui/index#/Orders/OrderApi_AddShipment)",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
orderId: {
12+
propDefinition: [
13+
app,
14+
"orderId",
15+
],
16+
},
17+
shippingProviderId: {
18+
propDefinition: [
19+
app,
20+
"shippingProviderId",
21+
],
22+
},
23+
shippingProviderProductId: {
24+
label: "Shipping Provider Product ID",
25+
description: "The ID of the shipping provider product/service",
26+
propDefinition: [
27+
app,
28+
"shipment",
29+
({
30+
orderId, shippingProviderId,
31+
}) => ({
32+
orderId,
33+
shippingProviderId,
34+
mapper: ({ ShippingProviderProductId: value }) => value,
35+
}),
36+
],
37+
},
38+
shippingId: {
39+
label: "Shipping ID",
40+
description: "The ID of the shipment",
41+
propDefinition: [
42+
app,
43+
"shipment",
44+
({
45+
orderId, shippingProviderId,
46+
}) => ({
47+
orderId,
48+
shippingProviderId,
49+
mapper: ({ ShippingId: value }) => value,
50+
}),
51+
],
52+
},
53+
carrierId: {
54+
propDefinition: [
55+
app,
56+
"carrierId",
57+
],
58+
},
59+
shipmentType: {
60+
propDefinition: [
61+
app,
62+
"shipmentType",
63+
],
64+
},
65+
comment: {
66+
type: "string",
67+
label: "Comment",
68+
description: "Additional comment for the shipment",
69+
optional: true,
70+
},
71+
},
72+
async run({ $ }) {
73+
const {
74+
app,
75+
orderId,
76+
shippingProviderId,
77+
shippingProviderProductId,
78+
comment,
79+
shippingId,
80+
carrierId,
81+
shipmentType,
82+
} = this;
83+
84+
await app.addShipmentToOrder({
85+
$,
86+
orderId,
87+
data: {
88+
ShippingProviderId: shippingProviderId,
89+
ShippingProviderProductId: shippingProviderProductId,
90+
Comment: comment,
91+
ShippingId: shippingId,
92+
CarrierId: carrierId,
93+
ShipmentType: shipmentType,
94+
},
95+
});
96+
97+
$.export("$summary", `Successfully added shipment to order \`${orderId}\``);
98+
99+
return {
100+
success: true,
101+
};
102+
},
103+
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import app from "../../billbee.app.mjs";
2+
3+
export default {
4+
key: "billbee-change-order-state",
5+
name: "Change Order State",
6+
description: "Change the state of an order. [See the documentation](https://app.billbee.io//swagger/ui/index#/Orders/OrderApi_UpdateState)",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
orderId: {
12+
propDefinition: [
13+
app,
14+
"orderId",
15+
],
16+
},
17+
newStateId: {
18+
type: "string",
19+
label: "New Order State",
20+
description: "The new state for the order",
21+
optional: false,
22+
propDefinition: [
23+
app,
24+
"orderStateId",
25+
],
26+
},
27+
},
28+
async run({ $ }) {
29+
const {
30+
app,
31+
orderId,
32+
newStateId,
33+
} = this;
34+
35+
await app.changeOrderState({
36+
$,
37+
orderId,
38+
data: {
39+
NewStateId: parseInt(newStateId),
40+
},
41+
});
42+
43+
$.export("$summary", "Successfully changed order state");
44+
45+
return {
46+
success: true,
47+
};
48+
},
49+
};
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import app from "../../billbee.app.mjs";
2+
3+
export default {
4+
key: "billbee-create-invoice-for-order",
5+
name: "Create Invoice For Order",
6+
description: "Create an invoice for an existing order. [See the documentation](https://app.billbee.io//swagger/ui/index#/Orders/OrderApi_CreateInvoice)",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
orderId: {
12+
propDefinition: [
13+
app,
14+
"orderId",
15+
],
16+
},
17+
templateId: {
18+
type: "string",
19+
label: "Template ID",
20+
description: "The ID of the invoice template to use",
21+
optional: true,
22+
},
23+
includeInvoicePdf: {
24+
type: "boolean",
25+
label: "Include Invoice PDF",
26+
description: "If true, the PDF is included in the response as base64 encoded string",
27+
optional: true,
28+
},
29+
sendToCloudId: {
30+
label: "Send To Cloud ID",
31+
propDefinition: [
32+
app,
33+
"cloudStorageId",
34+
],
35+
},
36+
},
37+
async run({ $ }) {
38+
const {
39+
app,
40+
orderId,
41+
templateId,
42+
includeInvoicePdf,
43+
sendToCloudId,
44+
} = this;
45+
46+
await app.createInvoiceForOrder({
47+
$,
48+
orderId,
49+
data: {
50+
TemplateId: templateId,
51+
IncludeInvoicePdf: includeInvoicePdf,
52+
SendToCloudId: sendToCloudId,
53+
},
54+
});
55+
56+
$.export("$summary", `Successfully created invoice for order \`${orderId}\``);
57+
58+
return {
59+
success: true,
60+
};
61+
},
62+
};
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import app from "../../billbee.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "billbee-create-order",
6+
name: "Create Order",
7+
description: "Create a new order. [See the documentation](https://app.billbee.io//swagger/ui/index#/Orders/OrderApi_PostNewOrder)",
8+
type: "action",
9+
version: "0.0.1",
10+
props: {
11+
app,
12+
orderData: {
13+
type: "object",
14+
label: "Order Data",
15+
description: `The data for the order. [See the documentation](https://app.billbee.io//swagger/ui/index#/Orders/OrderApi_PostNewOrder)
16+
17+
**Example:**
18+
\`\`\`json
19+
{
20+
"State": 1,
21+
"CreatedAt": "2025-09-04T00:00:00.000Z",
22+
"PaymentMethod": 1,
23+
"ShippingCost": 0,
24+
"TotalCost": 0,
25+
"OrderItems": [
26+
{
27+
"Product": {
28+
"Title": "Test 1"
29+
},
30+
"Quantity": 1,
31+
"TotalPrice": 0,
32+
"TaxAmount": 0,
33+
"TaxIndex": 19
34+
}
35+
]
36+
}
37+
\`\`\``,
38+
},
39+
},
40+
async run({ $ }) {
41+
const {
42+
app,
43+
orderData,
44+
} = this;
45+
46+
const response = await app.createOrder({
47+
$,
48+
data: utils.parse(orderData),
49+
});
50+
51+
$.export("$summary", `Successfully created order with ID \`${response.Data?.BillBeeOrderId}\``);
52+
53+
return response;
54+
},
55+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../billbee.app.mjs";
2+
3+
export default {
4+
key: "billbee-get-order-by-id",
5+
name: "Get Order By ID",
6+
description: "Retrieve a specific order by its ID from Billbee. [See the documentation](https://app.billbee.io//swagger/ui/index#/Orders/OrderApi_Get)",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
orderId: {
12+
propDefinition: [
13+
app,
14+
"orderId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const {
20+
app,
21+
orderId,
22+
} = this;
23+
24+
const response = await app.getOrder({
25+
$,
26+
orderId,
27+
});
28+
29+
$.export("$summary", `Successfully retrieved order with ID \`${response.Data?.BillBeeOrderId}\``);
30+
31+
return response;
32+
},
33+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import app from "../../billbee.app.mjs";
2+
3+
export default {
4+
key: "billbee-list-customers",
5+
name: "List Customers",
6+
description: "Retrieve a list of customers. [See the documentation](https://app.billbee.io/swagger/ui/index#/Customers/Customer_GetAll)",
7+
type: "action",
8+
version: "0.0.1",
9+
props: {
10+
app,
11+
max: {
12+
type: "integer",
13+
label: "Maximum Results",
14+
description: "Maximum number of customers to return",
15+
optional: true,
16+
},
17+
},
18+
async run({ $ }) {
19+
const {
20+
app,
21+
max,
22+
} = this;
23+
24+
const customers = await app.paginate({
25+
resourcesFn: app.listCustomers,
26+
resourcesFnArgs: {
27+
$,
28+
},
29+
resourceName: "Data",
30+
max,
31+
});
32+
33+
$.export("$summary", `Successfully retrieved \`${customers.length}\` customers`);
34+
35+
return customers;
36+
},
37+
};

0 commit comments

Comments
 (0)