export type GetApiQuoteImageSearchArgs = {category?: unknown | undefined, author?: unknown | undefined, private?: boolean | undefined}; export type GetApiQuoteImageSearchOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Gets a Random Quote image. Optional `category` param determines the category of quote used in the image. Optional `author` param gets the quote image of a given author. * * GET /quote/image/search */ export const getApiQuoteImageSearch = async (args: GetApiQuoteImageSearchArgs, options?: GetApiQuoteImageSearchOptions) => { 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.category != null) query.append("category", String(args.category)) if (args.author != null) query.append("author", String(args.author)) if (args.private != null) query.append("private", String(args.private)) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/quote/image/search${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 (await res.json()) as unknown };