Skip to content

Commit 8b76745

Browse files
committed
[Components] limoexpress #16907
Sources - New Booking Actions - Create Booking - Create Client - Mark Invoice As Paid
1 parent a31d6d1 commit 8b76745

File tree

14 files changed

+723
-401
lines changed

14 files changed

+723
-401
lines changed

components/limoexpress/actions/assign-driver/assign-driver.mjs

Lines changed: 0 additions & 41 deletions
This file was deleted.

components/limoexpress/actions/cancel-booking/cancel-booking.mjs

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 250 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { PRICE_TYPE_OPTIONS } from "../../common/constants.mjs";
2+
import { throwError } from "../../common/utils.mjs";
13
import limoexpress from "../../limoexpress.app.mjs";
2-
import { axios } from "@pipedream/platform";
34

45
export default {
56
key: "limoexpress-create-booking",
67
name: "Create Limo Booking",
7-
description: "Creates a new limo booking with specified details. [See the documentation](https://api.limoexpress.me/api/docs/v1)",
8+
description: "Creates a new limo booking with specified details. [See the documentation](https://api.limoexpress.me/api/docs/v1#/Bookings/createBooking)",
89
version: "0.0.1",
910
type: "action",
1011
props: {
@@ -22,50 +23,271 @@ export default {
2223
],
2324
optional: true,
2425
},
25-
fromLocation: {
26+
fromLocationName: {
27+
type: "string",
28+
label: "From Location Name",
29+
description: "The pickup location name.",
30+
},
31+
fromLocationFullAddress: {
32+
type: "string",
33+
label: "From Location Full Address",
34+
description: "The pickup location full address.",
35+
},
36+
fromLocationLatitude: {
37+
type: "string",
38+
label: "From Location Latitude",
39+
description: "The pickup location latitude.",
40+
optional: true,
41+
},
42+
fromLocationLongitude: {
43+
type: "string",
44+
label: "From Location Longitude",
45+
description: "The pickup location longitude.",
46+
optional: true,
47+
},
48+
toLocationName: {
49+
type: "string",
50+
label: "To Location Name",
51+
description: "The dropoff location name.",
52+
},
53+
toLocationFullAddress: {
54+
type: "string",
55+
label: "To Location Full Address",
56+
description: "The dropoff location full address.",
57+
},
58+
toLocationLatitude: {
59+
type: "string",
60+
label: "To Location Latitude",
61+
description: "The dropoff location latitude.",
62+
optional: true,
63+
},
64+
toLocationLongitude: {
65+
type: "string",
66+
label: "To Location Longitude",
67+
description: "The dropoff location longitude.",
68+
optional: true,
69+
},
70+
pickupTime: {
71+
type: "string",
72+
label: "Pickup Time",
73+
description: "The time scheduled for pickup. **Format: YYYY-MM-DD HH:MM:SS**",
74+
},
75+
expectedDropOffTime: {
76+
type: "string",
77+
label: "Expected Drop Off Time",
78+
description: "The expected drop off time. **Format: YYYY-MM-DD HH:MM:SS**",
79+
optional: true,
80+
},
81+
expectedComebackTime: {
82+
type: "string",
83+
label: "Expected Comeback Time",
84+
description: "The expected comeback time. **Format: YYYY-MM-DD HH:MM:SS**",
85+
optional: true,
86+
},
87+
vehicleClassId: {
2688
propDefinition: [
2789
limoexpress,
28-
"fromLocation",
90+
"vehicleClassId",
2991
],
92+
optional: true,
3093
},
31-
pickupTime: {
94+
vehicleId: {
3295
propDefinition: [
3396
limoexpress,
34-
"pickupTime",
97+
"vehicleId",
98+
({ vehicleClassId }) => ({
99+
vehicleClassId,
100+
}),
35101
],
102+
optional: true,
36103
},
37-
customerId: {
104+
price: {
38105
type: "string",
39-
label: "Customer ID",
40-
description: "ID of the customer for the booking.",
106+
label: "Price",
107+
description: "The price of the booking.",
108+
optional: true,
41109
},
42-
toLocation: {
110+
priceType: {
43111
type: "string",
44-
label: "To Location",
45-
description: "The dropoff location.",
112+
label: "Price Type",
113+
description: "The type of price for the booking.",
114+
options: PRICE_TYPE_OPTIONS,
46115
optional: true,
47116
},
48-
vehicleId: {
117+
commissionAmount: {
118+
type: "string",
119+
label: "Commission Amount",
120+
description: "The commission amount for the booking.",
121+
optional: true,
122+
},
123+
currencyId: {
124+
propDefinition: [
125+
limoexpress,
126+
"currencyId",
127+
],
128+
optional: true,
129+
},
130+
vatPercentage: {
49131
type: "string",
50-
label: "Vehicle ID",
51-
description: "ID of the vehicle to be used for the booking.",
132+
label: "VAT Percentage",
133+
description: "The VAT percentage for the booking.",
134+
optional: true,
135+
},
136+
paymentMethodId: {
137+
propDefinition: [
138+
limoexpress,
139+
"paymentMethodId",
140+
],
141+
optional: true,
142+
},
143+
distance: {
144+
type: "integer",
145+
label: "Distance",
146+
description: "Number of kilometers/miles that booking will take.",
147+
optional: true,
148+
},
149+
duration: {
150+
type: "string",
151+
label: "Duration",
152+
description: "Number of hours and minutes that booking will take. **Format: HH:MM**",
153+
optional: true,
154+
},
155+
paid: {
156+
type: "boolean",
157+
label: "Paid",
158+
description: "Flag that says is the booking paid or not.",
159+
optional: true,
160+
},
161+
confirmed: {
162+
type: "boolean",
163+
label: "Confirmed",
164+
description: "Flag that says is the booking confirmed or not.",
165+
optional: true,
166+
},
167+
roundTrip: {
168+
type: "boolean",
169+
label: "Round Trip",
170+
description: "Flag that says is the booking a round trip or not.",
171+
optional: true,
172+
},
173+
note: {
174+
type: "string",
175+
label: "Note",
176+
description: "Note for the dispatcher.",
177+
optional: true,
178+
},
179+
noteForDriver: {
180+
type: "string",
181+
label: "Note for Driver",
182+
description: "Note for the driver.",
183+
optional: true,
184+
},
185+
flightNumber: {
186+
type: "string",
187+
label: "Flight Number",
188+
description: "Flight number for the booking.",
189+
optional: true,
190+
},
191+
numOfWaitingHours: {
192+
type: "integer",
193+
label: "Number of Waiting Hours",
194+
description: "Number of waiting hours.",
195+
optional: true,
196+
},
197+
clientId: {
198+
propDefinition: [
199+
limoexpress,
200+
"clientId",
201+
],
202+
optional: true,
203+
},
204+
waitingBoardText: {
205+
type: "string",
206+
label: "Waiting Board Text",
207+
description: "Text that will be places on the waiting board.",
208+
optional: true,
209+
},
210+
babySeatCount: {
211+
type: "integer",
212+
label: "Baby Seat Count",
213+
description: "Number of baby seats that will be used for the booking.",
214+
optional: true,
215+
},
216+
suitcaseCount: {
217+
type: "integer",
218+
label: "Suitcase Count",
219+
description: "Number of suitcases that will be used for the booking.",
220+
optional: true,
221+
},
222+
checkpoints: {
223+
type: "string[]",
224+
label: "Checkpoints",
225+
description: "List of objects of checkpoints location and time. **Format: [{\"location\": { \"name\": string, \"full_address\": string, \"coordinates\": { \"lat\": number, \"lng\": number } }, \"time\": \"01:14\"}]**",
226+
optional: true,
227+
},
228+
passengers: {
229+
type: "string[]",
230+
label: "Passengers",
231+
description: "List of objects of passengers. **Format: [{\"first_name\": string, \"last_name\": string, \"phone\": string, \"email\": string, \"nationality\": string, \"passport\": string, \"country_id\": UUID }]",
52232
optional: true,
53233
},
54234
},
55235
async run({ $ }) {
56-
const response = await this.limoexpress.createBooking({
57-
bookingTypeId: this.bookingTypeId,
58-
fromLocation: this.fromLocation,
59-
pickupTime: this.pickupTime,
60-
additionalFields: {
61-
booking_status_id: this.bookingStatusId,
62-
customer_id: this.customerId,
63-
to_location: this.toLocation,
64-
vehicle_id: this.vehicleId,
65-
},
66-
});
236+
try {
237+
const response = await this.limoexpress.createBooking({
238+
$,
239+
data: {
240+
booking_type_id: this.bookingTypeId,
241+
booking_status_id: this.bookingStatusId,
242+
from_location: {
243+
name: this.fromLocationName,
244+
full_address: this.fromLocationFullAddress,
245+
coordinates: {
246+
lat: this.fromLocationLatitude,
247+
lng: this.fromLocationLongitude,
248+
},
249+
},
250+
to_location: {
251+
name: this.toLocationName,
252+
full_address: this.toLocationFullAddress,
253+
coordinates: {
254+
lat: this.toLocationLatitude,
255+
lng: this.toLocationLongitude,
256+
},
257+
},
258+
pickup_time: this.pickupTime,
259+
expected_drop_off_time: this.expectedDropOffTime,
260+
expected_comeback_time: this.expectedComebackTime,
261+
vehicle_class_id: this.vehicleClassId,
262+
vehicle_id: this.vehicleId,
263+
price: this.price && parseFloat(this.price),
264+
price_type: this.priceType,
265+
commission_amount: this.commissionAmount && parseFloat(this.commissionAmount),
266+
currency_id: this.currencyId,
267+
vat_percentage: this.vatPercentage && parseFloat(this.vatPercentage),
268+
payment_method_id: this.paymentMethodId,
269+
distance: this.distance,
270+
duration: this.duration,
271+
paid: this.paid,
272+
confirmed: this.confirmed,
273+
round_trip: this.roundTrip,
274+
note: this.note,
275+
note_for_driver: this.noteForDriver,
276+
flight_number: this.flightNumber,
277+
num_of_waiting_hours: this.numOfWaitingHours,
278+
client_id: this.clientId,
279+
waiting_board_text: this.waitingBoardText,
280+
baby_seat_count: this.babySeatCount,
281+
suitcase_count: this.suitcaseCount,
282+
checkpoints: this.checkpoints,
283+
passengers: this.passengers,
284+
},
285+
});
67286

68-
$.export("$summary", `Successfully created booking with ID ${response.id}`);
69-
return response;
287+
$.export("$summary", `Successfully created booking with ID ${response.data.id}`);
288+
return response;
289+
} catch ({ response }) {
290+
throwError(response);
291+
}
70292
},
71293
};

0 commit comments

Comments
 (0)