export type PatchApiQuoteArgs = {id: unknown, quote?: unknown | undefined, author?: unknown | undefined, language?: unknown | undefined, tags?: string | undefined}; export type PatchApiQuoteOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a quote * * PATCH /quote */ export const patchApiQuote = async (args: PatchApiQuoteArgs, options?: PatchApiQuoteOptions) => { 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.quote != null) query.append("quote", String(args.quote)) if (args.author != null) query.append("author", String(args.author)) if (args.language != null) query.append("language", String(args.language)) if (args.tags != null) query.append("tags", String(args.tags)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/quote${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 };