Merge branch 'develop' into feature/tracking
This commit is contained in:
+183
-21
@@ -2,28 +2,190 @@
|
||||
* Nested enum requires namespace
|
||||
*/
|
||||
export namespace endpoints {
|
||||
export const enum v0 {
|
||||
profile = "profile/v0/Profile",
|
||||
namespace base {
|
||||
export const enum path {
|
||||
availability = "availability",
|
||||
booking = "booking",
|
||||
hotel = "hotel",
|
||||
package = "package",
|
||||
profile = "profile",
|
||||
}
|
||||
|
||||
export const enum enitity {
|
||||
Ancillary = "Ancillary",
|
||||
Availabilities = "availabilities",
|
||||
Bookings = "Bookings",
|
||||
Breakfast = "breakfast",
|
||||
Cities = "Cities",
|
||||
Countries = "Countries",
|
||||
Hotels = "Hotels",
|
||||
Locations = "Locations",
|
||||
Packages = "packages",
|
||||
Profile = "Profile",
|
||||
Reward = "Reward",
|
||||
Stays = "Stays",
|
||||
Transaction = "Transaction",
|
||||
}
|
||||
}
|
||||
export const enum v1 {
|
||||
hotelsAvailability = "availability/v1/availabilities/city",
|
||||
roomsAvailability = "availability/v1/availabilities/hotel",
|
||||
profile = "profile/v1/Profile",
|
||||
booking = "booking/v1/Bookings",
|
||||
creditCards = `${profile}/creditCards`,
|
||||
city = "hotel/v1/Cities",
|
||||
citiesCountry = `${city}/country`,
|
||||
countries = "hotel/v1/Countries",
|
||||
friendTransactions = "profile/v1/Transaction/friendTransactions",
|
||||
hotels = "hotel/v1/Hotels",
|
||||
initiateSaveCard = `${creditCards}/initiateSaveCard`,
|
||||
locations = "hotel/v1/Locations",
|
||||
previousStays = "booking/v1/Stays/past",
|
||||
upcomingStays = "booking/v1/Stays/future",
|
||||
rewards = `${profile}/reward`,
|
||||
tierRewards = `${profile}/TierRewards`,
|
||||
subscriberId = `${profile}/SubscriberId`,
|
||||
|
||||
export namespace v1 {
|
||||
const version = "v1"
|
||||
/**
|
||||
* availability (Swagger)
|
||||
* https://tstapi.scandichotels.com/availability/swagger/v1/index.html
|
||||
*/
|
||||
export namespace Availability {
|
||||
export function city(cityId: string) {
|
||||
return `${base.path.availability}/${version}/${base.enitity.Availabilities}/city/${cityId}`
|
||||
}
|
||||
export function hotel(hotelId: string) {
|
||||
return `${base.path.availability}/${version}/${base.enitity.Availabilities}/hotel/${hotelId}`
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* booking (Swagger)
|
||||
* https://tstapi.scandichotels.com/booking/swagger/v1/index.html
|
||||
*/
|
||||
export namespace Booking {
|
||||
export const bookings = `${base.path.booking}/${version}/${base.enitity.Bookings}`
|
||||
|
||||
export function booking(confirmationNumber: string) {
|
||||
return `${bookings}/${confirmationNumber}`
|
||||
}
|
||||
export function cancel(confirmationNumber: string) {
|
||||
return `${bookings}/${confirmationNumber}/cancel`
|
||||
}
|
||||
export function status(confirmationNumber: string) {
|
||||
return `${bookings}/${confirmationNumber}/status`
|
||||
}
|
||||
|
||||
export const enum Stays {
|
||||
future = `${base.path.booking}/${version}/${base.enitity.Stays}/future`,
|
||||
past = `${base.path.booking}/${version}/${base.enitity.Stays}/past`,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* hotel (Swagger)
|
||||
* https://tstapi.scandichotels.com/hotel/swagger/v1/index.html
|
||||
*/
|
||||
export namespace Hotel {
|
||||
export const cities = `${base.path.hotel}/${version}/${base.enitity.Cities}`
|
||||
export namespace Cities {
|
||||
export function city(cityId: string) {
|
||||
return `${cities}/${cityId}`
|
||||
}
|
||||
export function country(countryId: string) {
|
||||
return `${cities}/country/${countryId}`
|
||||
}
|
||||
export function hotel(hotelId: string) {
|
||||
return `${cities}/hotel/${hotelId}`
|
||||
}
|
||||
}
|
||||
|
||||
export const countries = `${base.path.hotel}/${version}/${base.enitity.Countries}`
|
||||
export namespace Countries {
|
||||
export function country(countryId: string) {
|
||||
return `${countries}/${countryId}`
|
||||
}
|
||||
}
|
||||
|
||||
export const hotels = `${base.path.hotel}/${version}/${base.enitity.Hotels}`
|
||||
export namespace Hotels {
|
||||
export function hotel(hotelId: string) {
|
||||
return `${hotels}/${hotelId}`
|
||||
}
|
||||
export function meetingRooms(hotelId: string) {
|
||||
return `${hotels}/${hotelId}/meetingRooms`
|
||||
}
|
||||
export function merchantInformation(hotelId: string) {
|
||||
return `${hotels}/${hotelId}/merchantInformation`
|
||||
}
|
||||
export function nearbyHotels(hotelId: string) {
|
||||
return `${hotels}/${hotelId}/nearbyHotels`
|
||||
}
|
||||
export function restaurants(hotelId: string) {
|
||||
return `${hotels}/${hotelId}/restaurants`
|
||||
}
|
||||
export function roomCategories(hotelId: string) {
|
||||
return `${hotels}/${hotelId}/roomCategories`
|
||||
}
|
||||
}
|
||||
|
||||
export const locations = `${base.path.hotel}/${version}/${base.enitity.Locations}`
|
||||
}
|
||||
|
||||
/**
|
||||
* package (Swagger)
|
||||
* https://tstapi.scandichotels.com/package/swagger/v1/index.html
|
||||
*/
|
||||
export namespace Package {
|
||||
export namespace Ancillary {
|
||||
export function hotel(hotelId: string) {
|
||||
return `${base.path.package}/${version}/${base.enitity.Ancillary}/hotel/${hotelId}`
|
||||
}
|
||||
export function hotelAncillaries(hotelId: string) {
|
||||
return `${base.path.package}/${version}/${base.enitity.Ancillary}/hotel/${hotelId}/ancillaries`
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Breakfast {
|
||||
export function hotel(hotelId: string) {
|
||||
return `${base.path.package}/${version}/${base.enitity.Breakfast}/hotel/${hotelId}`
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Packages {
|
||||
export function hotel(hotelId: string) {
|
||||
return `${base.path.package}/${version}/${base.enitity.Packages}/hotel/${hotelId}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* profile (Swagger)
|
||||
* https://tstapi.scandichotels.com/profile/swagger/v1/index.html
|
||||
*/
|
||||
export namespace Profile {
|
||||
export const invalidateSessions = `${base.path.profile}/${version}/${base.enitity.Profile}/invalidateSessions`
|
||||
export const membership = `${base.path.profile}/${version}/${base.enitity.Profile}/membership`
|
||||
export const profile = `${base.path.profile}/${version}/${base.enitity.Profile}`
|
||||
export const reward = `${base.path.profile}/${version}/${base.enitity.Profile}/reward`
|
||||
export const subscriberId = `${base.path.profile}/${version}/${base.enitity.Profile}/SubscriberId`
|
||||
export const tierRewards = `${base.path.profile}/${version}/${base.enitity.Profile}/tierRewards`
|
||||
|
||||
export function deleteProfile(profileId: string) {
|
||||
return `${profile}/${profileId}`
|
||||
}
|
||||
|
||||
export const creditCards = `${base.path.profile}/${version}/${base.enitity.Profile}/creditCards`
|
||||
export namespace CreditCards {
|
||||
export const initiateSaveCard = `${creditCards}/initiateSaveCard`
|
||||
|
||||
export function deleteCreditCard(creditCardId: string) {
|
||||
return `${creditCards}/${creditCardId}`
|
||||
}
|
||||
export function transaction(transactionId: string) {
|
||||
return `${creditCards}/${transactionId}`
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Reward {
|
||||
export const allTiers = `${base.path.profile}/${version}/${base.enitity.Reward}/AllTiers`
|
||||
export const reward = `${base.path.profile}/${version}/${base.enitity.Reward}`
|
||||
export const unwrap = `${base.path.profile}/${version}/${base.enitity.Reward}/Unwrap`
|
||||
|
||||
export function claim(rewardId: string) {
|
||||
return `${base.path.profile}/${version}/${base.enitity.Reward}/Claim/${rewardId}`
|
||||
}
|
||||
}
|
||||
|
||||
export const enum Transaction {
|
||||
friendTransactions = `${base.path.profile}/${version}/${base.enitity.Transaction}/friendTransactions`,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type Endpoint = endpoints.v0 | endpoints.v1
|
||||
export type Endpoint = string
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ const wrappedFetch = fetchRetry(fetch, {
|
||||
})
|
||||
|
||||
export async function get(
|
||||
endpoint: Endpoint | `${Endpoint}/${string}`,
|
||||
endpoint: Endpoint,
|
||||
options: RequestOptionsWithOutBody,
|
||||
params = {}
|
||||
) {
|
||||
@@ -37,7 +37,7 @@ export async function get(
|
||||
const searchParams = new URLSearchParams(params)
|
||||
if (searchParams.size) {
|
||||
searchParams.forEach((value, key) => {
|
||||
url.searchParams.set(key, value)
|
||||
url.searchParams.append(key, value)
|
||||
})
|
||||
url.searchParams.sort()
|
||||
}
|
||||
|
||||
@@ -26,6 +26,9 @@ query GetContentPage($locale: String!, $uid: String!) {
|
||||
preamble
|
||||
...NavigationLinks
|
||||
}
|
||||
blocks {
|
||||
__typename
|
||||
}
|
||||
sidebar {
|
||||
__typename
|
||||
...ContentSidebar_ContentPage
|
||||
|
||||
@@ -52,14 +52,46 @@ export const getUserTracking = cache(async function getMemoizedUserTracking() {
|
||||
|
||||
export const getHotelData = cache(async function getMemoizedHotelData(
|
||||
hotelId: string,
|
||||
language: string
|
||||
language: string,
|
||||
isCardOnlyPayment?: boolean
|
||||
) {
|
||||
return serverClient().hotel.hotelData.get({
|
||||
hotelId,
|
||||
language,
|
||||
isCardOnlyPayment,
|
||||
})
|
||||
})
|
||||
|
||||
export const getRoomAvailability = cache(
|
||||
async function getMemoizedRoomAvailability({
|
||||
hotelId,
|
||||
adults,
|
||||
roomStayStartDate,
|
||||
roomStayEndDate,
|
||||
children,
|
||||
promotionCode,
|
||||
rateCode,
|
||||
}: {
|
||||
hotelId: string
|
||||
adults: number
|
||||
roomStayStartDate: string
|
||||
roomStayEndDate: string
|
||||
children?: string
|
||||
promotionCode?: string
|
||||
rateCode?: string
|
||||
}) {
|
||||
return serverClient().hotel.availability.rooms({
|
||||
hotelId: parseInt(hotelId),
|
||||
adults,
|
||||
roomStayStartDate,
|
||||
roomStayEndDate,
|
||||
children,
|
||||
promotionCode,
|
||||
rateCode,
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
export const getFooter = cache(async function getMemoizedFooter() {
|
||||
return serverClient().contentstack.base.footer()
|
||||
})
|
||||
@@ -89,3 +121,9 @@ export const getLanguageSwitcher = cache(
|
||||
export const getSiteConfig = cache(async function getMemoizedSiteConfig() {
|
||||
return serverClient().contentstack.base.siteConfig()
|
||||
})
|
||||
|
||||
export const getBreakfastPackages = cache(async function getMemoizedPackages(
|
||||
hotelId: string
|
||||
) {
|
||||
return serverClient().hotel.packages.breakfast({ hotelId })
|
||||
})
|
||||
|
||||
@@ -6,7 +6,6 @@ import { login } from "@/constants/routes/handleAuth"
|
||||
import { webviews } from "@/constants/routes/webviews"
|
||||
import { appRouter } from "@/server"
|
||||
import { createContext } from "@/server/context"
|
||||
import { internalServerError } from "@/server/errors/next"
|
||||
import { createCallerFactory } from "@/server/trpc"
|
||||
|
||||
const createCaller = createCallerFactory(appRouter)
|
||||
|
||||
Reference in New Issue
Block a user