export type PatchApiBusServicesIdArgs = {id: number, body: {bus_id: number, service_date: string, details: string, odometer?: number | undefined, carried_out_by?: string | undefined, amount: number, currency: string}}; export type PatchApiBusServicesIdOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update item by ID and return it if success. Permission: bus_service_maintenance * * PATCH /bus_services/{id} */ export const patchApiBusServicesId = async (args: PatchApiBusServicesIdArgs, options?: PatchApiBusServicesIdOptions) => { 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(/\/+$/, '')}/bus_services/${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 };