/** * Reservation-related types */ import { ChannelType, ListingId, PaginationParams, TimeOfDay } from './common.js'; /** * Reservation status */ export type ReservationStatus = | 'wait_accept' | 'wait_pay' | 'accepted' | 'cancelled' | 'denied' | 'timeout'; /** * Guest ID type */ export type GuestIdType = 'passport' | 'id_card' | 'others'; /** * Guest gender */ export type GuestGender = 'male' | 'female'; /** * Reservation query order by */ export type ReservationOrderBy = | 'booked_at' | 'check_in_date' | 'check_out_date' | 'cancelled_at' | 'created_at'; /** * Stay status */ export type StayStatus = 'checkin_pending' | 'in_house' | 'stay_completed'; /** * ID-registration requirement level for a stay * - `not_required`: no ID required * - `required`: guest must upload an ID, no manual review * - `required_with_review`: guest must upload an ID and the host must approve it */ export type IdRequiredLevel = 'not_required' | 'required' | 'required_with_review'; /** * An additional fee parsed from channel remarks (e.g. city tax) */ export interface AdditionalFee { /** The name of the fee item, as provided by the channel */ name?: string; /** The currency code of the fee */ currency?: string; /** The amount of the fee */ amount?: number; } /** * An ID document image uploaded through the online check-in guide */ export interface CheckinGuideImage { /** Internal ID of the image record */ id?: number; /** ID of the guest this image is linked to; null if not yet associated */ client_id?: number | null; /** Extra-large variant URL of the uploaded image */ url?: string | null; } /** * An ID document image uploaded for a specific guest */ export interface GuestIdImage { /** Internal ID of the image record */ id?: number; /** Extra-large variant URL of the uploaded image */ url?: string | null; } /** * Tax amount of a reservation */ export interface ReservationTax { /** The currency code */ currency?: string; /** The tax amount */ amount?: number; } /** * Guest information */ export interface Guest { /** Guest ID */ id: number; /** Guest name */ name: string | null; /** Guest phone */ phone: string | null; /** Guest email */ email: string | null; /** ID type */ id_type?: GuestIdType | null; /** ID number */ id_number?: string | null; /** Gender */ gender?: GuestGender | null; /** Country (ISO 3166-1 Alpha-2) */ country?: string | null; /** Whether this is the booker */ is_booker: boolean; /** ID document images uploaded for this guest */ id_images?: GuestIdImage[]; } /** * Rate detail item */ export interface RateDetail { /** Type of the rate detail */ type: string; /** Description of the rate detail */ description: string; /** Currency code */ currency: string; /** Amount */ amount: number; } /** * Reservation rates */ export interface ReservationRates { /** The order rate includes commission */ total_rate?: { currency: string; amount: number; }; /** The total commission of the order */ total_commission?: { currency: string; amount: number; }; /** The reservation rate includes commission */ rate?: { currency: string; amount: number; }; /** The commission of the reservation */ commission?: { currency: string; amount: number; }; /** The rate details of the reservation */ details?: RateDetail[]; /** The taxes of the reservation; null if the reservation has no taxes */ tax?: ReservationTax | null; } /** * Check-in details */ export interface CheckInDetails { /** The arrival time of the reservation */ arrival_at?: TimeOfDay | null; /** The departure time of the reservation */ departure_at?: TimeOfDay | null; /** The lock code of the reservation */ lock_code?: string | null; /** The lock code will be visible after this time (HH:mm format) */ lock_code_visible_after?: string; /** The deposit amount in the host's currency */ deposit?: number; /** ID-registration requirement for this stay (defaults to not_required) */ id_required?: IdRequiredLevel; /** The check-in guide URL */ check_in_guide_url?: string; } /** * Custom channel */ export interface CustomChannel { /** ID of the custom channel */ id: number; /** Name of the custom channel */ name: string; } /** * Reservation information */ export interface Reservation { /** The reservation code */ reservation_code: string; /** The stay code of the reservation */ stay_code: string; /** The reservation ID in the channel */ channel_id: string; /** The property ID */ property_id: number; /** The type of the channel */ channel_type: ChannelType; /** The listing ID */ listing_id: ListingId; /** The check-in date (YYYY-MM-DD) */ check_in_date: string; /** The check-out date (YYYY-MM-DD) */ check_out_date: string; /** The total number of guests */ number_of_guests: number; /** The number of adults */ number_of_adults?: number; /** The number of children */ number_of_children?: number; /** The number of infants */ number_of_infants?: number; /** The number of pets */ number_of_pets?: number; /** Reservation status */ status: ReservationStatus; /** The default name of the guest */ guest_name?: string | null; /** The default phone of the guest */ guest_phone?: string | null; /** The default email of the guest */ guest_email?: string | null; /** When the reservation was cancelled (ISO 8601) */ cancelled_at?: string | null; /** When the reservation was booked (ISO 8601) */ booked_at: string; /** When the reservation was created in Hostex (ISO 8601) */ created_at: string; /** The creator name of the reservation */ creator?: string; /** Rates information */ rates?: ReservationRates; /** Check-in details */ check_in_details?: CheckInDetails; /** Remarks from the Hostex Host Portal */ remarks?: string; /** Remarks from the channel */ channel_remarks?: string; /** The conversation ID */ conversation_id?: string; /** Tags from the Hostex Host Portal */ tags?: string[]; /** Custom channel */ custom_channel?: CustomChannel; /** Guest information */ guests?: Guest[]; /** Custom fields */ custom_fields?: Record | null; /** Whether the reservation is in the reservation box */ in_reservation_box?: boolean; /** Additional fees parsed from channel remarks (e.g. city tax) */ additional_fees?: AdditionalFee[]; /** ID images uploaded via the online check-in guide for this reservation */ checkin_guide_images?: CheckinGuideImage[]; } /** * Reservations query parameters */ export interface ReservationsQueryParams extends PaginationParams { /** Filter by reservation code */ reservation_code?: string; /** Filter by property ID */ property_id?: number; /** Filter by status */ status?: ReservationStatus; /** Filter by check-in date start (inclusive) */ start_check_in_date?: string; /** Filter by check-in date end (inclusive) */ end_check_in_date?: string; /** Filter by check-out date start (inclusive) */ start_check_out_date?: string; /** Filter by check-out date end (inclusive) */ end_check_out_date?: string; /** Sort by field */ order_by?: ReservationOrderBy; /** Filter by channel type */ channel_type?: ChannelType; /** Filters by the reservation ID in the channel (matches the channel_id response field) */ channel_id?: string; } /** * Create reservation parameters */ export interface CreateReservationParams { /** The id of the property for the reservation */ property_id: string; /** The id of the custom channel */ custom_channel_id: number; /** The check-in date (YYYY-MM-DD) */ check_in_date: string; /** The check-out date (YYYY-MM-DD) */ check_out_date: string; /** The total number of guests */ number_of_guests?: number; /** The name of the primary guest */ guest_name: string; /** The email address of the primary guest */ email?: string; /** The mobile phone number of the primary guest */ mobile?: string; /** The currency code */ currency: string; /** The total rate amount */ rate_amount: number; /** The commission amount */ commission_amount: number; /** The total amount received */ received_amount: number; /** The income method ID */ income_method_id: number; /** Additional remarks */ remarks?: string; } /** * Update check-in details parameters */ export interface UpdateCheckInDetailsParams { /** The stay code */ stay_code: string; /** The lock code (set to null to remove) */ lock_code?: string | null; /** Time after which lock code is visible (HH:mm format, set to null to remove) */ lock_code_visible_after?: string | null; /** Expected arrival time (set to null to remove) */ arrival_at?: TimeOfDay | null; /** Expected departure time (set to null to remove) */ departure_at?: TimeOfDay | null; /** Deposit amount in host's currency */ deposit?: number; /** ID-registration requirement for this stay */ id_required?: IdRequiredLevel; } /** * Update reservation basic info parameters */ export interface UpdateReservationBasicInfoParams { /** * The stay code the update targets (the API path is /reservations/{stay_code}) */ stay_code?: string; /** * The reservation code * @deprecated Use stay_code — the API targets the stay */ reservation_code?: string; /** Remarks for the reservation */ remarks?: string; /** The account of the creator */ creator?: string; /** The id of the custom channel */ custom_channel_id?: number; /** The check-in date (YYYY-MM-DD) */ check_in_date?: string; /** The check-out date (YYYY-MM-DD) */ check_out_date?: string; /** The total number of guests */ number_of_guests?: number; /** The name of the primary guest */ guest_name?: string; /** The mobile phone number of the guest */ mobile?: string; /** The email address of the guest */ email?: string; /** The currency code */ currency?: string; /** The total rate amount (0-999999) */ rate_amount?: number; /** The commission amount (0-999999) */ commission_amount?: number; } /** * Update stay status parameters */ export interface UpdateStayStatusParams { /** The stay code */ stay_code: string; /** The new stay status */ stay_status: StayStatus; } /** * Add tag parameters */ export interface AddTagParams { /** The stay code */ stay_code: string; /** The tag name to add */ tag_name: string; } /** * Remove tag parameters */ export interface RemoveTagParams { /** The stay code */ stay_code: string; /** The tag name to remove */ tag_name: string; } /** * Move to box parameters */ export interface MoveToBoxParams { /** The stay code to move to the box */ stay_code: string; } /** * Allocate to property parameters */ export interface AllocateToPropertyParams { /** The stay code to allocate */ stay_code: string; /** The property ID to allocate to */ property_id: number; } /** * Custom fields update parameters */ export interface UpdateCustomFieldsParams { /** The stay code */ stay_code: string; /** Custom fields to update (set to null to delete) */ custom_fields: Record; } /** * Custom fields response */ export interface CustomFieldsData { /** Custom fields */ custom_fields: Record | null; } /** * Reservations response data */ export interface ReservationsData { /** List of reservations */ reservations: Reservation[]; } /** * Custom channels response data */ export interface CustomChannelsData { /** List of custom channels */ custom_channels: CustomChannel[]; } /** * Income method */ export interface IncomeMethod { /** ID of the income method */ id: number; /** Name of the income method */ name: string; } /** * Income methods response data * Note: OpenAPI spec has a bug where the field is named "custom_channels" * but required field is "income_methods". We include both for compatibility. */ export interface IncomeMethodsData { /** List of income methods (semantic name) */ income_methods?: IncomeMethod[]; // /** List of income methods (from OpenAPI spec - appears to be a bug) */ // custom_channels?: IncomeMethod[]; } /** * Create reservation response data */ export interface CreateReservationData { /** The created reservation */ reservation: { /** The reservation code */ reservation_code: string; }; }