Skip to content

Commit d629389

Browse files
committed
[Components] Paazl new components
1 parent 43c37a6 commit d629389

File tree

18 files changed

+2383
-10
lines changed

18 files changed

+2383
-10
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");
33+
return response;
34+
},
35+
};
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
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+
type: {
18+
optional: false,
19+
propDefinition: [
20+
app,
21+
"labelType",
22+
],
23+
},
24+
size: {
25+
optional: false,
26+
propDefinition: [
27+
app,
28+
"labelSize",
29+
],
30+
},
31+
quantity: {
32+
propDefinition: [
33+
app,
34+
"quantity",
35+
],
36+
},
37+
enableParcels: {
38+
propDefinition: [
39+
app,
40+
"enableParcels",
41+
],
42+
},
43+
parcelWeight: {
44+
propDefinition: [
45+
app,
46+
"parcelWeight",
47+
],
48+
},
49+
parcelLength: {
50+
propDefinition: [
51+
app,
52+
"parcelLength",
53+
],
54+
},
55+
parcelWidth: {
56+
propDefinition: [
57+
app,
58+
"parcelWidth",
59+
],
60+
},
61+
parcelHeight: {
62+
propDefinition: [
63+
app,
64+
"parcelHeight",
65+
],
66+
},
67+
parcelVolume: {
68+
propDefinition: [
69+
app,
70+
"parcelVolume",
71+
],
72+
},
73+
parcelReference: {
74+
propDefinition: [
75+
app,
76+
"parcelReference",
77+
],
78+
},
79+
parcelDescription: {
80+
propDefinition: [
81+
app,
82+
"parcelDescription",
83+
],
84+
},
85+
parcelCodValue: {
86+
propDefinition: [
87+
app,
88+
"parcelCodValue",
89+
],
90+
},
91+
parcelCodCurrency: {
92+
propDefinition: [
93+
app,
94+
"parcelCodCurrency",
95+
],
96+
},
97+
parcelInsuredValue: {
98+
propDefinition: [
99+
app,
100+
"parcelInsuredValue",
101+
],
102+
},
103+
parcelInsuredCurrency: {
104+
propDefinition: [
105+
app,
106+
"parcelInsuredCurrency",
107+
],
108+
},
109+
},
110+
async run({ $ }) {
111+
const {
112+
app,
113+
orderReference,
114+
type,
115+
size,
116+
quantity,
117+
enableParcels,
118+
parcelWeight,
119+
parcelLength,
120+
parcelWidth,
121+
parcelHeight,
122+
parcelVolume,
123+
parcelReference,
124+
parcelDescription,
125+
parcelCodValue,
126+
parcelCodCurrency,
127+
parcelInsuredValue,
128+
parcelInsuredCurrency,
129+
} = this;
130+
131+
const response = await app.createShipment({
132+
$,
133+
orderReference,
134+
data: {
135+
type,
136+
size,
137+
quantity,
138+
...(enableParcels && parcelWeight
139+
? {
140+
parcels: [
141+
{
142+
weight: parseFloat(parcelWeight),
143+
...(parcelLength && parcelWidth && parcelHeight
144+
? {
145+
dimensions: {
146+
length: parcelLength,
147+
width: parcelWidth,
148+
height: parcelHeight,
149+
...(parcelVolume
150+
? {
151+
volume: parseFloat(parcelVolume),
152+
}
153+
: {}
154+
),
155+
},
156+
}
157+
: parcelVolume
158+
? {
159+
dimensions: {
160+
volume: parseFloat(parcelVolume),
161+
},
162+
}
163+
: {}
164+
),
165+
reference: parcelReference,
166+
description: parcelDescription,
167+
...(parcelCodValue
168+
? {
169+
codValue: {
170+
value: parseFloat(parcelCodValue),
171+
currency: parcelCodCurrency || "EUR",
172+
},
173+
}
174+
: {}
175+
),
176+
...(parcelInsuredValue
177+
? {
178+
insuredValue: {
179+
value: parseFloat(parcelInsuredValue),
180+
currency: parcelInsuredCurrency || "EUR",
181+
},
182+
}
183+
: {}
184+
),
185+
},
186+
],
187+
}
188+
: {}
189+
),
190+
},
191+
});
192+
193+
$.export("$summary", `Successfully created shipment for order: ${orderReference}`);
194+
return response;
195+
},
196+
};
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");
33+
return response;
34+
},
35+
};
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
size,
46+
},
47+
});
48+
49+
$.export("$summary", `Successfully retrieved labels for order: ${orderReference}`);
50+
return response;
51+
},
52+
};
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");
30+
return response;
31+
},
32+
};

0 commit comments

Comments
 (0)