Skip to content

Commit 6b9fc55

Browse files
authored
Merging pull request #18309
* new components * pnpm-lock.yaml
1 parent 212cd8b commit 6b9fc55

File tree

5 files changed

+656
-6
lines changed

5 files changed

+656
-6
lines changed
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
import fedex from "../../fedex.app.mjs";
2+
3+
export default {
4+
key: "fedex-create-shipment",
5+
name: "Create Shipment",
6+
description: "Create a new shipment. [See the documentation](https://developer.fedex.com/api/en-us/catalog/ship/docs.html#operation/Create%20Shipment)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
fedex,
11+
accountNumber: {
12+
propDefinition: [
13+
fedex,
14+
"accountNumber",
15+
],
16+
},
17+
shipperStreetLines: {
18+
propDefinition: [
19+
fedex,
20+
"shipperStreetLines",
21+
],
22+
},
23+
shipperCity: {
24+
propDefinition: [
25+
fedex,
26+
"shipperCity",
27+
],
28+
},
29+
shipperStateOrProvinceCode: {
30+
propDefinition: [
31+
fedex,
32+
"shipperStateOrProvinceCode",
33+
],
34+
},
35+
shipperPostalCode: {
36+
propDefinition: [
37+
fedex,
38+
"shipperPostalCode",
39+
],
40+
},
41+
shipperCountryCode: {
42+
propDefinition: [
43+
fedex,
44+
"shipperCountryCode",
45+
],
46+
},
47+
shipperContactName: {
48+
propDefinition: [
49+
fedex,
50+
"shipperContactName",
51+
],
52+
},
53+
shipperPhoneNumber: {
54+
propDefinition: [
55+
fedex,
56+
"shipperPhoneNumber",
57+
],
58+
},
59+
recipientStreetLines: {
60+
propDefinition: [
61+
fedex,
62+
"recipientStreetLines",
63+
],
64+
},
65+
recipientCity: {
66+
propDefinition: [
67+
fedex,
68+
"recipientCity",
69+
],
70+
},
71+
recipientStateOrProvinceCode: {
72+
propDefinition: [
73+
fedex,
74+
"recipientStateOrProvinceCode",
75+
],
76+
},
77+
recipientPostalCode: {
78+
propDefinition: [
79+
fedex,
80+
"recipientPostalCode",
81+
],
82+
},
83+
recipientCountryCode: {
84+
propDefinition: [
85+
fedex,
86+
"recipientCountryCode",
87+
],
88+
},
89+
recipientContactName: {
90+
propDefinition: [
91+
fedex,
92+
"recipientContactName",
93+
],
94+
},
95+
recipientPhoneNumber: {
96+
propDefinition: [
97+
fedex,
98+
"recipientPhoneNumber",
99+
],
100+
},
101+
pickupType: {
102+
propDefinition: [
103+
fedex,
104+
"pickupType",
105+
],
106+
},
107+
serviceType: {
108+
propDefinition: [
109+
fedex,
110+
"serviceType",
111+
],
112+
},
113+
packagingType: {
114+
propDefinition: [
115+
fedex,
116+
"packagingType",
117+
],
118+
},
119+
totalWeight: {
120+
propDefinition: [
121+
fedex,
122+
"totalWeight",
123+
],
124+
},
125+
paymentType: {
126+
propDefinition: [
127+
fedex,
128+
"paymentType",
129+
],
130+
},
131+
labelFormatType: {
132+
propDefinition: [
133+
fedex,
134+
"labelFormatType",
135+
],
136+
},
137+
labelStockType: {
138+
propDefinition: [
139+
fedex,
140+
"labelStockType",
141+
],
142+
},
143+
imageType: {
144+
propDefinition: [
145+
fedex,
146+
"imageType",
147+
],
148+
},
149+
weightUnit: {
150+
propDefinition: [
151+
fedex,
152+
"weightUnit",
153+
],
154+
},
155+
weights: {
156+
propDefinition: [
157+
fedex,
158+
"weights",
159+
],
160+
},
161+
},
162+
async run({ $ }) {
163+
const response = await this.fedex.createShipment({
164+
$,
165+
data: {
166+
accountNumber: {
167+
value: this.accountNumber,
168+
},
169+
labelResponseOptions: "URL_ONLY",
170+
requestedShipment: {
171+
shipper: {
172+
address: {
173+
streetLines: this.shipperStreetLines,
174+
city: this.shipperCity,
175+
stateOrProvinceCode: this.shipperStateOrProvinceCode,
176+
postalCode: this.shipperPostalCode,
177+
countryCode: this.shipperCountryCode,
178+
},
179+
contact: {
180+
personName: this.shipperContactName,
181+
phoneNumber: this.shipperPhoneNumber,
182+
},
183+
},
184+
recipients: [
185+
{
186+
address: {
187+
streetLines: this.recipientStreetLines,
188+
city: this.recipientCity,
189+
stateOrProvinceCode: this.recipientStateOrProvinceCode,
190+
postalCode: this.recipientPostalCode,
191+
countryCode: this.recipientCountryCode,
192+
},
193+
contact: {
194+
personName: this.recipientContactName,
195+
phoneNumber: this.recipientPhoneNumber,
196+
},
197+
},
198+
],
199+
pickupType: this.pickupType,
200+
serviceType: this.serviceType,
201+
packagingType: this.packagingType,
202+
totalWeight: +this.totalWeight,
203+
shippingChargesPayment: {
204+
paymentType: this.paymentType,
205+
},
206+
labelSpecification: {
207+
labelFormatType: this.labelFormatType,
208+
labelStockType: this.labelStockType,
209+
imageType: this.imageType,
210+
},
211+
requestedPackageLineItems: this.weights.map((weight) => ({
212+
weight: {
213+
units: this.weightUnit,
214+
value: +weight,
215+
},
216+
})),
217+
},
218+
},
219+
});
220+
$.export("$summary", "Shipment created successfully");
221+
return response;
222+
},
223+
};

0 commit comments

Comments
 (0)