1import { FerryClient } from "@ferryvn/sdk";
2const ferry = new FerryClient({ apiKey: process.env.FERRY_API_KEY });
3
4// Pier names match with or without accents
5const [from] = await ferry.locations.find("Rạch Giá");
6const [to] = await ferry.locations.find("phu quoc");
7const { data } = await ferry.voyages.search({
8 date, departureId: from.id, destinationId: to.id,
9});
10
11// Picks ticket types by age, matches prices, checks seats
12const { booking, draft } = await ferry.bookingDrafts.create({
13 customerId, ordererName, contactEmail,
14 depart: { voyageId: data[0].voyage.id, seats: ["A1"], passengers },
15});
16
17// Charges your balance, orders from the operator
18await ferry.bookings.confirmToIssue(booking.id);
19const { booking_status } = await ferry.bookings.get(booking.id);