Files
web/apps/scandic-web/lib/api/endpoints.ts
Anton Gunnarsson 80100e7631 Merged in monorepo-step-1 (pull request #1080)
Migrate to a monorepo setup - step 1

* Move web to subfolder /apps/scandic-web

* Yarn + transitive deps

- Move to yarn
- design-system package removed for now since yarn doesn't
support the parameter for token (ie project currently broken)
- Add missing transitive dependencies as Yarn otherwise
prevents these imports
- VS Code doesn't pick up TS path aliases unless you open
/apps/scandic-web instead of root (will be fixed with monorepo)

* Pin framer-motion to temporarily fix typing issue

https://github.com/adobe/react-spectrum/issues/7494

* Pin zod to avoid typ error

There seems to have been a breaking change in the types
returned by zod where error is now returned as undefined
instead of missing in the type. We should just handle this
but to avoid merge conflicts just pin the dependency for
now.

* Pin react-intl version

Pin version of react-intl to avoid tiny type issue where formatMessage
does not accept a generic any more. This will be fixed in a future
commit, but to avoid merge conflicts just pin for now.

* Pin typescript version

Temporarily pin version as newer versions as stricter and results in
a type error. Will be fixed in future commit after merge.

* Setup workspaces

* Add design-system as a monorepo package

* Remove unused env var DESIGN_SYSTEM_ACCESS_TOKEN

* Fix husky for monorepo setup

* Update netlify.toml

* Add lint script to root package.json

* Add stub readme

* Fix react-intl formatMessage types

* Test netlify.toml in root

* Remove root toml

* Update netlify.toml publish path

* Remove package-lock.json

* Update build for branch/preview builds


Approved-by: Linus Flood
2025-02-26 10:36:17 +00:00

210 lines
7.4 KiB
TypeScript

/**
* Nested enum requires namespace
*/
export namespace endpoints {
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 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 hotels() {
return `${base.path.availability}/${version}/${base.enitity.Availabilities}/hotels`
}
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 function priceChange(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/priceChange`
}
export function packages(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/packages`
}
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 function additionalData(hotelId: string) {
return `${hotels}/${hotelId}/additionalData`
}
}
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 subscriberId = `${base.path.profile}/${version}/${base.enitity.Profile}/SubscriberId`
export const link = `${base.path.profile}/${version}/${base.enitity.Profile}/link`
export const unlink = `${base.path.profile}/${version}/${base.enitity.Profile}/Unlink`
// TODO: Remove once new endpoints are out in production.
export const reward = `${base.path.profile}/${version}/${base.enitity.Profile}/reward`
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 redeem = `${base.path.profile}/${version}/${base.enitity.Reward}/redeem`
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 = string