export type PatchApiQshowArgs = {id: unknown, title?: unknown | undefined, description?: unknown | undefined, tags?: Array | undefined}; export type PatchApiQshowOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update an existing qshow. * * PATCH /qshow */ export const patchApiQshow = async (args: PatchApiQshowArgs, options?: PatchApiQshowOptions) => { const {baseUrl = "https://quotes.rest", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.id != null) query.append("id", String(args.id)) if (args.title != null) query.append("title", String(args.title)) if (args.description != null) query.append("description", String(args.description)) for (const item of args.tags ?? []) query.append("tags", String(item)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/qshow${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return (await res.json()) as unknown };