export type CreateApiClientTicketsBookingByCodesArgs = {body: {ticket_type: 'one_way', trip_id: number, 'departure[code]': string, 'departure[code_system]'?: ('operator' | 'starmart') | undefined, 'arrival[code]': string, 'arrival[code_system]'?: ('operator' | 'starmart') | undefined, departure_date: string, pax: number, number_seats: string, currency: 'MYR' | 'SGD', 'customer[name]'?: string | undefined, 'customer[phone]'?: string | undefined, 'customer[ic]'?: string | undefined, 'customer[email]'?: string | undefined, qr_check_in?: boolean | undefined, idempotency_key?: string | undefined}}; export type CreateApiClientTicketsBookingByCodesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Booking by trip_id + station codes (station-operator POS). Resolves trip_segment_id internally and reserves the seats. The reservation must be confirmed with POST /tickets/:ticket_id/confirm before it expires. Auth: agent/staff. * * POST /client/tickets/booking_by_codes */ export const createApiClientTicketsBookingByCodes = async (args: CreateApiClientTicketsBookingByCodesArgs, options?: CreateApiClientTicketsBookingByCodesOptions) => { 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/booking_by_codes${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 };