export type GetApiPettyCashesTripsArgs = {trip_id?: number | undefined, start_departure_date?: string | undefined, end_departure_date?: string | undefined, 'coach[departure_station_id]'?: number | undefined, only_with_claims?: (0 | 1) | undefined}; export type GetApiPettyCashesTripsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List of trips petty cash * * GET /petty_cashes/trips */ export const getApiPettyCashesTrips = async (args: GetApiPettyCashesTripsArgs, options?: GetApiPettyCashesTripsOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.trip_id != null) query.append("trip_id", String(args.trip_id)) if (args.start_departure_date != null) query.append("start_departure_date", String(args.start_departure_date)) if (args.end_departure_date != null) query.append("end_departure_date", String(args.end_departure_date)) if (args['coach[departure_station_id]'] != null) query.append("coach[departure_station_id]", String(args['coach[departure_station_id]'])) if (args.only_with_claims != null) query.append("only_with_claims", String(args.only_with_claims)) const url = `${baseUrl.replace(/\/+$/, '')}/petty_cashes/trips${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 };