Skip to content

Commit 40f99c6

Browse files
authored
Sendcloud - new components (#18043)
1 parent 49c436e commit 40f99c6

File tree

34 files changed

+3169
-286
lines changed

34 files changed

+3169
-286
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import app from "../../sendcloud.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "sendcloud-bulk-pdf-label-printing",
6+
name: "Bulk PDF Label Printing",
7+
description: "Bulk PDF label printing. [See the documentation](https://api.sendcloud.dev/docs/sendcloud-public-api/branches/v2/labels/operations/create-a-label)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
parcels: {
13+
type: "integer[]",
14+
label: "Parcel IDs",
15+
description: "IDs of parcels to print labels. Example: [1, 2, 3]",
16+
propDefinition: [
17+
app,
18+
"parcelId",
19+
],
20+
},
21+
},
22+
async run({ $ }) {
23+
const {
24+
app,
25+
parcels,
26+
} = this;
27+
28+
const response = await app.bulkPDFLabelPrinting({
29+
$,
30+
data: {
31+
label: {
32+
parcels: utils.parseArray(parcels),
33+
},
34+
},
35+
});
36+
37+
$.export("$summary", "Successfully triggered bulk label print");
38+
39+
return response;
40+
},
41+
};
42+

components/sendcloud/actions/create-a-parcel/create-a-parcel.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "sendcloud-create-a-parcel",
55
name: "Create a Parcel",
66
description: "Creates a new parcel under your Sendcloud API credentials. [See the documentation](https://api.sendcloud.dev/docs/sendcloud-public-api/parcels/operations/create-a-parcel)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
import app from "../../sendcloud.app.mjs";
2+
import utils from "../../common/utils.mjs";
3+
4+
export default {
5+
key: "sendcloud-create-return",
6+
name: "Create Return",
7+
description: "Create a return. [See the documentation](https://api.sendcloud.dev/docs/sendcloud-public-api/returns/operations/create-a-return)",
8+
version: "0.0.1",
9+
type: "action",
10+
props: {
11+
app,
12+
fromAddress: {
13+
label: "From Address",
14+
propDefinition: [
15+
app,
16+
"addressSetup",
17+
],
18+
},
19+
toAddress: {
20+
label: "To Address",
21+
propDefinition: [
22+
app,
23+
"addressSetup",
24+
],
25+
},
26+
shipWith: {
27+
propDefinition: [
28+
app,
29+
"shipWith",
30+
],
31+
},
32+
dimensionsLength: {
33+
propDefinition: [
34+
app,
35+
"dimensionsLength",
36+
],
37+
},
38+
dimensionsWidth: {
39+
propDefinition: [
40+
app,
41+
"dimensionsWidth",
42+
],
43+
},
44+
dimensionsHeight: {
45+
propDefinition: [
46+
app,
47+
"dimensionsHeight",
48+
],
49+
},
50+
dimensionsUnit: {
51+
propDefinition: [
52+
app,
53+
"dimensionsUnit",
54+
],
55+
},
56+
weightValue: {
57+
propDefinition: [
58+
app,
59+
"weightValue",
60+
],
61+
},
62+
weightUnit: {
63+
propDefinition: [
64+
app,
65+
"weightUnit",
66+
],
67+
},
68+
},
69+
async run({ $ }) {
70+
const {
71+
app,
72+
fromAddress,
73+
toAddress,
74+
shipWith,
75+
dimensionsLength,
76+
dimensionsWidth,
77+
dimensionsHeight,
78+
dimensionsUnit,
79+
weightValue,
80+
weightUnit,
81+
} = this;
82+
83+
const response = await app.createReturn({
84+
$,
85+
data: {
86+
from_address: utils.parseJson(fromAddress),
87+
to_address: utils.parseJson(toAddress),
88+
ship_with: utils.parseJson(shipWith),
89+
...(dimensionsLength
90+
&& dimensionsWidth
91+
&& dimensionsHeight
92+
&& dimensionsUnit
93+
? {
94+
dimensions: {
95+
length: dimensionsLength,
96+
width: dimensionsWidth,
97+
height: dimensionsHeight,
98+
unit: dimensionsUnit,
99+
},
100+
}
101+
: undefined
102+
),
103+
...(weightValue && weightUnit
104+
? {
105+
weight: {
106+
value: weightValue,
107+
unit: weightUnit,
108+
},
109+
}
110+
: undefined
111+
),
112+
},
113+
});
114+
115+
$.export("$summary", "Successfully created return");
116+
117+
return response;
118+
},
119+
};
120+

0 commit comments

Comments
 (0)