feat(SW-176): add schemas
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
export namespace endpoints {
|
export namespace endpoints {
|
||||||
export const enum v0 {
|
export const enum v0 {
|
||||||
profile = "profile/v0/Profile",
|
profile = "profile/v0/Profile",
|
||||||
|
availability = "availability/v0/availabilities/city",
|
||||||
}
|
}
|
||||||
export const enum v1 {
|
export const enum v1 {
|
||||||
profile = "profile/v1/Profile",
|
profile = "profile/v1/Profile",
|
||||||
|
|||||||
@@ -6,6 +6,17 @@ export const getHotelInputSchema = z.object({
|
|||||||
.optional(),
|
.optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const getAvailabilityInputSchema = z.object({
|
||||||
|
cityId: z.string(),
|
||||||
|
roomStayStartDate: z.string(),
|
||||||
|
roomStayEndDate: z.string(),
|
||||||
|
adults: z.number(),
|
||||||
|
children: z.number().optional(),
|
||||||
|
promotionCode: z.string().optional(),
|
||||||
|
reservationProfileType: z.string().optional(),
|
||||||
|
attachedProfileId: z.string().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
export const getRatesInputSchema = z.object({
|
export const getRatesInputSchema = z.object({
|
||||||
hotelId: z.string(),
|
hotelId: z.string(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -468,6 +468,64 @@ export const getHotelDataSchema = z.object({
|
|||||||
included: z.array(roomSchema).optional(),
|
included: z.array(roomSchema).optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const occupancySchema = z.object({
|
||||||
|
adults: z.number(),
|
||||||
|
children: z.number(),
|
||||||
|
})
|
||||||
|
|
||||||
|
const bestPricePerStaySchema = z.object({
|
||||||
|
currency: z.string(),
|
||||||
|
amount: z.number(),
|
||||||
|
regularAmount: z.number(),
|
||||||
|
memberAmount: z.number(),
|
||||||
|
discountRate: z.number(),
|
||||||
|
discountAmount: z.number(),
|
||||||
|
points: z.number(),
|
||||||
|
numberOfVouchers: z.number(),
|
||||||
|
numberOfBonusCheques: z.number(),
|
||||||
|
})
|
||||||
|
|
||||||
|
const bestPricePerNightSchema = z.object({
|
||||||
|
currency: z.string(),
|
||||||
|
amount: z.number(),
|
||||||
|
regularAmount: z.number(),
|
||||||
|
memberAmount: z.number(),
|
||||||
|
discountRate: z.number(),
|
||||||
|
discountAmount: z.number(),
|
||||||
|
points: z.number(),
|
||||||
|
numberOfVouchers: z.number(),
|
||||||
|
numberOfBonusCheques: z.number(),
|
||||||
|
})
|
||||||
|
|
||||||
|
const linksSchema = z.object({
|
||||||
|
links: z.array(
|
||||||
|
z.object({
|
||||||
|
url: z.string(),
|
||||||
|
type: z.string(),
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
const availabilitySchema = z.object({
|
||||||
|
data: z.array(
|
||||||
|
z.object({
|
||||||
|
attributes: z.object({
|
||||||
|
checkInDate: z.date(),
|
||||||
|
checkOutDate: z.date(),
|
||||||
|
occupancy: occupancySchema,
|
||||||
|
status: z.string(),
|
||||||
|
hotelId: z.number(),
|
||||||
|
ratePlanSet: z.string(),
|
||||||
|
bestPricePerStay: bestPricePerStaySchema,
|
||||||
|
bestPricePerNight: bestPricePerNightSchema,
|
||||||
|
}),
|
||||||
|
relationships: linksSchema,
|
||||||
|
})
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const getAvailabilitySchema = availabilitySchema
|
||||||
|
|
||||||
const flexibilityPrice = z.object({
|
const flexibilityPrice = z.object({
|
||||||
standard: z.number(),
|
standard: z.number(),
|
||||||
member: z.number(),
|
member: z.number(),
|
||||||
|
|||||||
@@ -21,11 +21,13 @@ import {
|
|||||||
validateHotelPageSchema,
|
validateHotelPageSchema,
|
||||||
} from "../contentstack/hotelPage/output"
|
} from "../contentstack/hotelPage/output"
|
||||||
import {
|
import {
|
||||||
|
getAvailabilityInputSchema,
|
||||||
getFiltersInputSchema,
|
getFiltersInputSchema,
|
||||||
getHotelInputSchema,
|
getHotelInputSchema,
|
||||||
getRatesInputSchema,
|
getRatesInputSchema,
|
||||||
} from "./input"
|
} from "./input"
|
||||||
import {
|
import {
|
||||||
|
getAvailabilitySchema,
|
||||||
getFiltersSchema,
|
getFiltersSchema,
|
||||||
getHotelDataSchema,
|
getHotelDataSchema,
|
||||||
getRatesSchema,
|
getRatesSchema,
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
import { getHotelDataSchema, roomSchema } from "@/server/routers/hotels/output"
|
import {
|
||||||
|
getAvailabilitySchema,
|
||||||
|
getHotelDataSchema,
|
||||||
|
roomSchema,
|
||||||
|
} from "@/server/routers/hotels/output"
|
||||||
|
|
||||||
export type HotelData = z.infer<typeof getHotelDataSchema>
|
export type HotelData = z.infer<typeof getHotelDataSchema>
|
||||||
|
|
||||||
@@ -14,3 +18,5 @@ export type HotelTripAdvisor =
|
|||||||
| undefined
|
| undefined
|
||||||
|
|
||||||
export type RoomData = z.infer<typeof roomSchema>
|
export type RoomData = z.infer<typeof roomSchema>
|
||||||
|
|
||||||
|
export type Availability = z.infer<typeof getAvailabilitySchema>
|
||||||
|
|||||||
Reference in New Issue
Block a user