export type GetApiTripTemplatesSegmentPricesArgs = {coach_id: number}; export type GetApiTripTemplatesSegmentPricesOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get trip template segment prices by coach code * * GET /trip_templates/segment_prices */ export const getApiTripTemplatesSegmentPrices = async (args: GetApiTripTemplatesSegmentPricesArgs, options?: GetApiTripTemplatesSegmentPricesOptions) => { const {baseUrl = "http://api.gostarmartbus.com/api", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.coach_id != null) query.append("coach_id", String(args.coach_id)) const url = `${baseUrl.replace(/\/+$/, '')}/trip_templates/segment_prices${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 };