export type PatchApiBusesIdArgs = {id: number, body: {plate_number: string, seat_profile_id?: number | undefined, cts_plate_number?: string | undefined, engine_model?: string | undefined, chassis_model?: string | undefined, seats: number, manufactured_date?: string | undefined, registration_date?: string | undefined, permit_exp?: string | undefined, insurance_exp?: string | undefined, road_tax_exp_sin?: string | undefined, road_tax_exp_mas?: string | undefined, omnibus_license_exp?: string | undefined, puspakom_exp?: string | undefined, bus_company_id?: number | undefined}}; export type PatchApiBusesIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update item by ID and return it if success. Permission: bus_maintenance * * PATCH /buses/{id} */ export const patchApiBusesId = async (args: PatchApiBusesIdArgs, options?: PatchApiBusesIdOptions) => { 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(/\/+$/, '')}/buses/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };