This implements the actual call to the API to create a booking. That’s the only thing it does, it doesn’t handle the response in any way. This PR is just to get it there and the new booking sub team will handle it further, with payment etc. Approved-by: Michael Zetterberg Approved-by: Fredrik Thorsson Approved-by: Simon.Emanuelsson
35 lines
932 B
TypeScript
35 lines
932 B
TypeScript
import { z } from "zod"
|
|
|
|
export const createBookingSchema = z
|
|
.object({
|
|
data: z.object({
|
|
attributes: z.object({
|
|
confirmationNumber: z.string(),
|
|
cancellationNumber: z.string().nullable(),
|
|
reservationStatus: z.string(),
|
|
paymentUrl: z.string().nullable(),
|
|
}),
|
|
type: z.string(),
|
|
id: z.string(),
|
|
links: z.object({
|
|
self: z.object({
|
|
href: z.string().url(),
|
|
meta: z.object({
|
|
method: z.string(),
|
|
}),
|
|
}),
|
|
}),
|
|
}),
|
|
})
|
|
.transform((d) => ({
|
|
id: d.data.id,
|
|
links: d.data.links,
|
|
type: d.data.type,
|
|
confirmationNumber: d.data.attributes.confirmationNumber,
|
|
cancellationNumber: d.data.attributes.cancellationNumber,
|
|
reservationStatus: d.data.attributes.reservationStatus,
|
|
paymentUrl: d.data.attributes.paymentUrl,
|
|
}))
|
|
|
|
type CreateBookingData = z.infer<typeof createBookingSchema>
|