export type GetApiTripsTripIdWaybillArgs = {template?: ('driver' | 'seating_list') | undefined, trip_id: number}; export type GetApiTripsTripIdWaybillOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Print trip waybill. Supported format: .json, .pdf, .html, .xls. (Permission: print_way_bill) * * GET /trips/{trip_id}/waybill */ export const getApiTripsTripIdWaybill = async (args: GetApiTripsTripIdWaybillArgs, options?: GetApiTripsTripIdWaybillOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.template != null) query.append("template", String(args.template)) const url = `${baseUrl.replace(/\/+$/, '')}/trips/${encodeURIComponent(String(args.trip_id))}/waybill${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 };