Skip to content

Commit df1102d

Browse files
committed
[Components] Paazl new components
1 parent e9191fc commit df1102d

File tree

18 files changed

+2356
-583
lines changed

18 files changed

+2356
-583
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import app from "../../paazl.app.mjs";
2+
3+
export default {
4+
key: "paazl-create-checkout-token",
5+
name: "Create Checkout Access Token",
6+
description: "Returns an access token for a checkout session. This enables the Paazl checkout widget to access Paazl resources. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Checkout/createTokenUsingPOST)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
reference: {
12+
propDefinition: [
13+
app,
14+
"reference",
15+
],
16+
description: "Your reference for the checkout session. If the reference value provided already exists, the existing session will be replaced with a new session.",
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
reference,
23+
} = this;
24+
25+
const response = await app.createCheckoutToken({
26+
$,
27+
data: {
28+
reference,
29+
},
30+
});
31+
32+
$.export("$summary", `Successfully created checkout token for reference: ${reference}`);
33+
return response;
34+
},
35+
};
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
import app from "../../paazl.app.mjs";
2+
3+
export default {
4+
key: "paazl-create-shipment",
5+
name: "Create Shipment For Order",
6+
description: "Generates a shipment at the carrier for the shipping option specified in POST order. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/createShipmentUsingPOST)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
orderReference: {
12+
propDefinition: [
13+
app,
14+
"orderReference",
15+
],
16+
},
17+
labelType: {
18+
propDefinition: [
19+
app,
20+
"labelType",
21+
],
22+
},
23+
labelSize: {
24+
propDefinition: [
25+
app,
26+
"labelSize",
27+
],
28+
},
29+
quantity: {
30+
propDefinition: [
31+
app,
32+
"quantity",
33+
],
34+
},
35+
enableParcels: {
36+
propDefinition: [
37+
app,
38+
"enableParcels",
39+
],
40+
},
41+
parcelWeight: {
42+
propDefinition: [
43+
app,
44+
"parcelWeight",
45+
],
46+
},
47+
parcelLength: {
48+
propDefinition: [
49+
app,
50+
"parcelLength",
51+
],
52+
},
53+
parcelWidth: {
54+
propDefinition: [
55+
app,
56+
"parcelWidth",
57+
],
58+
},
59+
parcelHeight: {
60+
propDefinition: [
61+
app,
62+
"parcelHeight",
63+
],
64+
},
65+
parcelVolume: {
66+
propDefinition: [
67+
app,
68+
"parcelVolume",
69+
],
70+
},
71+
parcelReference: {
72+
propDefinition: [
73+
app,
74+
"parcelReference",
75+
],
76+
},
77+
parcelDescription: {
78+
propDefinition: [
79+
app,
80+
"parcelDescription",
81+
],
82+
},
83+
parcelCodValue: {
84+
propDefinition: [
85+
app,
86+
"parcelCodValue",
87+
],
88+
},
89+
parcelCodCurrency: {
90+
propDefinition: [
91+
app,
92+
"parcelCodCurrency",
93+
],
94+
},
95+
parcelInsuredValue: {
96+
propDefinition: [
97+
app,
98+
"parcelInsuredValue",
99+
],
100+
},
101+
parcelInsuredCurrency: {
102+
propDefinition: [
103+
app,
104+
"parcelInsuredCurrency",
105+
],
106+
},
107+
},
108+
async run({ $ }) {
109+
const {
110+
app,
111+
orderReference,
112+
labelType,
113+
labelSize,
114+
quantity,
115+
enableParcels,
116+
parcelWeight,
117+
parcelLength,
118+
parcelWidth,
119+
parcelHeight,
120+
parcelVolume,
121+
parcelReference,
122+
parcelDescription,
123+
parcelCodValue,
124+
parcelCodCurrency,
125+
parcelInsuredValue,
126+
parcelInsuredCurrency,
127+
} = this;
128+
129+
const response = await app.createShipment({
130+
$,
131+
orderReference,
132+
data: {
133+
type: labelType,
134+
size: labelSize,
135+
quantity,
136+
...(enableParcels && parcelWeight
137+
? {
138+
parcels: [
139+
{
140+
weight: parseFloat(parcelWeight),
141+
...(parcelLength && parcelWidth && parcelHeight
142+
? {
143+
dimensions: {
144+
length: parcelLength,
145+
width: parcelWidth,
146+
height: parcelHeight,
147+
...(parcelVolume
148+
? {
149+
volume: parseFloat(parcelVolume),
150+
}
151+
: {}
152+
),
153+
},
154+
}
155+
: parcelVolume
156+
? {
157+
dimensions: {
158+
volume: parseFloat(parcelVolume),
159+
},
160+
}
161+
: {}
162+
),
163+
reference: parcelReference,
164+
description: parcelDescription,
165+
...(parcelCodValue
166+
? {
167+
codValue: {
168+
value: parseFloat(parcelCodValue),
169+
currency: parcelCodCurrency || "EUR",
170+
},
171+
}
172+
: {}
173+
),
174+
...(parcelInsuredValue
175+
? {
176+
insuredValue: {
177+
value: parseFloat(parcelInsuredValue),
178+
currency: parcelInsuredCurrency || "EUR",
179+
},
180+
}
181+
: {}
182+
),
183+
},
184+
],
185+
}
186+
: {}
187+
),
188+
},
189+
});
190+
191+
$.export("$summary", `Successfully created shipment for order: ${orderReference}`);
192+
return response;
193+
},
194+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import app from "../../paazl.app.mjs";
2+
3+
export default {
4+
key: "paazl-delete-order",
5+
name: "Delete Order",
6+
description: "Deletes an order. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Order/saveOrderUsingPOST)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
reference: {
12+
propDefinition: [
13+
app,
14+
"reference",
15+
],
16+
description: "Your reference for the order you want to delete",
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
reference,
23+
} = this;
24+
25+
const response = await app.deleteOrder({
26+
$,
27+
reference,
28+
});
29+
30+
$.export("$summary", `Successfully deleted order with reference: ${reference}`);
31+
return response;
32+
},
33+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import app from "../../paazl.app.mjs";
2+
3+
export default {
4+
key: "paazl-get-checkout-session",
5+
name: "Get Checkout Session Data",
6+
description: "Gets your reference for a checkout session. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Checkout/getCheckoutUsingGET)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
reference: {
12+
propDefinition: [
13+
app,
14+
"reference",
15+
],
16+
description: "Your reference for the checkout session whose details you want to retrieve. The reference is the one you used when you created an access token with the token endpoint.",
17+
},
18+
},
19+
async run({ $ }) {
20+
const {
21+
app,
22+
reference,
23+
} = this;
24+
25+
const response = await app.getCheckoutSession({
26+
$,
27+
params: {
28+
reference,
29+
},
30+
});
31+
32+
$.export("$summary", `Successfully retrieved checkout session data for reference: ${reference}`);
33+
return response;
34+
},
35+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import app from "../../paazl.app.mjs";
2+
3+
export default {
4+
key: "paazl-get-order-labels",
5+
name: "Get Order Shipping Labels",
6+
description: "Retrieves an order's labels. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getOrderLabelsUsingGet)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
orderReference: {
12+
propDefinition: [
13+
app,
14+
"orderReference",
15+
],
16+
},
17+
type: {
18+
propDefinition: [
19+
app,
20+
"labelType",
21+
],
22+
description: "Format of the labels",
23+
},
24+
size: {
25+
propDefinition: [
26+
app,
27+
"labelSize",
28+
],
29+
description: "Size of the labels",
30+
},
31+
},
32+
async run({ $ }) {
33+
const {
34+
app,
35+
orderReference,
36+
type,
37+
size,
38+
} = this;
39+
40+
const response = await app.getOrderLabels({
41+
$,
42+
orderReference,
43+
params: {
44+
...(type && {
45+
type,
46+
}),
47+
...(size && {
48+
size,
49+
}),
50+
},
51+
});
52+
53+
$.export("$summary", `Successfully retrieved labels for order: ${orderReference}`);
54+
return response;
55+
},
56+
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import app from "../../paazl.app.mjs";
2+
3+
export default {
4+
key: "paazl-get-order-shipments",
5+
name: "Get Order Shipment Details",
6+
description: "Retrieves an order's shipments details. [See the documentation](https://support.paazl.com/hc/en-us/articles/360008633973-REST-API-reference#/Shipments/getShipmentsUsingGET)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
orderReference: {
12+
propDefinition: [
13+
app,
14+
"orderReference",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const {
20+
app,
21+
orderReference,
22+
} = this;
23+
24+
const response = await app.getOrderShipments({
25+
$,
26+
orderReference,
27+
});
28+
29+
$.export("$summary", `Successfully retrieved shipment details for order: ${orderReference}`);
30+
return response;
31+
},
32+
};

0 commit comments

Comments
 (0)