export type GetApiTicketsArgs = {'pagination[limit]'?: number | undefined, 'pagination[page]'?: number | undefined, departure_date?: string | undefined, uid?: string | undefined, user_name?: string | undefined, user_phone?: string | undefined, user_ic?: string | undefined, trip_id?: string | undefined, departure_station_id?: string | undefined, arrival_station_id?: string | undefined, show_uncollected?: ('0' | '1') | undefined}; export type GetApiTicketsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search ticket. Permission: trip_query * * GET /tickets */ export const getApiTickets = async (args: GetApiTicketsArgs, options?: GetApiTicketsOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args['pagination[limit]'] != null) query.append("pagination[limit]", String(args['pagination[limit]'])) if (args['pagination[page]'] != null) query.append("pagination[page]", String(args['pagination[page]'])) if (args.departure_date != null) query.append("departure_date", String(args.departure_date)) if (args.uid != null) query.append("uid", String(args.uid)) if (args.user_name != null) query.append("user_name", String(args.user_name)) if (args.user_phone != null) query.append("user_phone", String(args.user_phone)) if (args.user_ic != null) query.append("user_ic", String(args.user_ic)) if (args.trip_id != null) query.append("trip_id", String(args.trip_id)) if (args.departure_station_id != null) query.append("departure_station_id", String(args.departure_station_id)) if (args.arrival_station_id != null) query.append("arrival_station_id", String(args.arrival_station_id)) if (args.show_uncollected != null) query.append("show_uncollected", String(args.show_uncollected)) const url = `${baseUrl.replace(/\/+$/, '')}/tickets${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };