export type EnquiryTypes = 1 | 2; export type TravellerTitles = 0 | 1 | 2 | 3 | 4 | 5 | 6; export type EnquiryCriteria = {enquiryType: EnquiryTypes, title: TravellerTitles, firstname: string, surname: string, emailAddress?: (string | null) | undefined, telPrefix?: (string | null) | undefined, telNumber?: (string | null) | undefined, callbackIn?: number | undefined}; export type CreateApiEnquirySearchIdSearchKeyArgs = {searchId: number, searchKey: string, interactSession?: string | undefined, accommodation?: string | undefined, body: EnquiryCriteria}; export type CreateApiEnquirySearchIdSearchKeyOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Submits an enquiry for a search session. * * POST /enquiry/{searchId}/{searchKey} */ export const createApiEnquirySearchIdSearchKey = async (args: CreateApiEnquirySearchIdSearchKeyArgs, options?: CreateApiEnquirySearchIdSearchKeyOptions) => { const {baseUrl = "https://api.travelify.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.interactSession != null) query.append("interactSession", String(args.interactSession)) if (args.accommodation != null) query.append("accommodation", String(args.accommodation)) const url = `${baseUrl.replace(/\/+$/, '')}/enquiry/${encodeURIComponent(String(args.searchId))}/${encodeURIComponent(String(args.searchKey))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };