export type CreateApiClientTicketsArgs = {body: {ticket_type: 'one_way' | 'return', pax: number, 'one_way_trip[trip_segment_id]': number, 'one_way_trip[departure_date]'?: string | undefined, 'one_way_trip[number_seats]': string, 'one_way_trip[currency]': 'MYR' | 'SGD', 'one_way_trip[overwritten_price]'?: number | undefined, 'one_way_trip[qr_check_in]'?: boolean | undefined, 'return_trip[trip_segment_id]': number, 'return_trip[departure_date]'?: string | undefined, 'return_trip[number_seats]': string, 'return_trip[currency]': 'MYR' | 'SGD', 'return_trip[overwritten_price]'?: number | undefined, 'return_trip[qr_check_in]'?: boolean | undefined, user_name?: string | undefined, user_phone?: string | undefined, user_ic?: string | undefined, user_email?: string | undefined}}; export type CreateApiClientTicketsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Deprecated method: Should use /booking instead * * POST /client/tickets */ export const createApiClientTickets = async (args: CreateApiClientTicketsArgs, options?: CreateApiClientTicketsOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") const url = `${baseUrl.replace(/\/+$/, '')}/client/tickets${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };