Files
web/packages/trpc/lib/api/endpoints.ts
Matilda Landström 22dd2f60fe Merged in feat/LOY-431-profile-v2 (pull request #3202)
Feat/LOY-431: Switch to V2 of Profile endpoint

* feat(LOY-431): switch to v2 of profile endpoint

* feat(LOY-431): use CreditCard

* feat(LOY-431): remove hotelinformation from friendTransaction schema

* chore(LOY-431): add hotel data request to transactions

* fix(LOY-431): use v1 of friendTransactions


Approved-by: Linus Flood
Approved-by: Erik Tiekstra
Approved-by: Anton Gunnarsson
2025-11-28 13:58:06 +00:00

249 lines
8.1 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",
CreditCard = "CreditCard",
Hotels = "Hotels",
Locations = "Locations",
Packages = "packages",
Profile = "Profile",
Reward = "Reward",
Stays = "Stays",
Transaction = "Transaction",
RoomFeature = "RoomFeature",
}
}
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}`
}
export function roomFeatures(hotelId: string) {
return `${base.path.availability}/${version}/${base.enitity.RoomFeature}/features/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 find(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/find`
}
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 function guarantee(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/guarantee`
}
export function confirmNotification(confirmationNumber: string) {
return `${bookings}/${confirmationNumber}/confirmNotification`
}
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 enum Transaction {
friendTransactions = `${base.path.profile}/${version}/${base.enitity.Transaction}/friendTransactions`,
}
}
}
export namespace v2 {
const version = "v2"
/**
* profile (Swagger)
* https://tstapi.scandichotels.com/profile/swagger/v2/index.html
*/
export namespace Profile {
export const profile = `${base.path.profile}/${version}/${base.enitity.Profile}`
export const basicProfile = `${profile}/BasicInfo`
export const promoCampaign = `${profile}/Promotion`
export const membership = `${profile}/membership`
export const subscriberId = `${profile}/SubscriberId`
export const invalidateSessions = `${profile}/invalidateSessions`
export const link = `${profile}/link`
export const unlink = `${profile}/Unlink`
export const matchTier = `${profile}/MatchTier`
export const pointTransfer = `${profile}/PointTransfer/Partner`
export function deleteProfile(profileId: string) {
return `${profile}/${profileId}`
}
export function teamMemberCard(employeeId: string) {
return `${profile}/${employeeId}/TeamMemberCard`
}
export namespace CreditCard {
export const creditCard = `${base.path.profile}/${version}/${base.enitity.CreditCard}`
export const initiateSaveCard = `${creditCard}/initiateSaveCard`
export function deleteCreditCard(creditCardId: string) {
return `${creditCard}/${creditCardId}`
}
export function transaction(transactionId: string) {
return `${creditCard}/${transactionId}`
}
}
export namespace Reward {
export const reward = `${base.path.profile}/${version}/${base.enitity.Reward}`
export const allTiers = `${reward}/allTiers`
export const redeem = `${reward}/redeem`
export const unwrap = `${reward}/unwrap`
export function claim(rewardId: string) {
return `${reward}/Claim/${rewardId}`
}
}
/* Currently no hotelInformation in v2 */
export const enum Transaction {
friendTransactions = `${base.path.profile}/${version}/${base.enitity.Transaction}/friendTransactions`,
}
}
}
}
export type Endpoint = string