export type GetApiApiArtworksArgs = {offset?: number | undefined, size?: number | undefined, cursor?: string | undefined, sample?: string | undefined, term?: string | undefined, page?: number | undefined, exact?: boolean | undefined, artist_id?: string | undefined, partner_id?: string | undefined, show_id?: string | undefined, collection_id?: string | undefined, user_id?: string | undefined, similar_to_artwork_id?: string | undefined, published?: boolean | undefined}; export type GetApiApiArtworksOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve a collection of artworks. * * GET /api/artworks */ export const getApiApiArtworks = async (args: GetApiApiArtworksArgs, options: GetApiApiArtworksOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.offset != null) query.append("offset", String(args.offset)) if (args.size != null) query.append("size", String(args.size)) if (args.cursor != null) query.append("cursor", String(args.cursor)) if (args.sample != null) query.append("sample", String(args.sample)) if (args.term != null) query.append("term", String(args.term)) if (args.page != null) query.append("page", String(args.page)) if (args.exact != null) query.append("exact", String(args.exact)) if (args.artist_id != null) query.append("artist_id", String(args.artist_id)) if (args.partner_id != null) query.append("partner_id", String(args.partner_id)) if (args.show_id != null) query.append("show_id", String(args.show_id)) if (args.collection_id != null) query.append("collection_id", String(args.collection_id)) if (args.user_id != null) query.append("user_id", String(args.user_id)) if (args.similar_to_artwork_id != null) query.append("similar_to_artwork_id", String(args.similar_to_artwork_id)) if (args.published != null) query.append("published", String(args.published)) const url = `${baseUrl.replace(/\/+$/, '')}/api/artworks${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 undefined };