export type GetApiApiSaleArtworksArgs = {offset?: number | undefined, size?: string | undefined, cursor?: string | undefined, sale_id?: string | undefined, published?: boolean | undefined, artwork_id?: string | undefined, sort?: ('position' | 'end_at' | '-end_at' | 'timely_at') | undefined}; export type GetApiApiSaleArtworksOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve sale artworks. * * GET /api/sale_artworks */ export const getApiApiSaleArtworks = async (args: GetApiApiSaleArtworksArgs, options: GetApiApiSaleArtworksOptions) => { 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.sale_id != null) query.append("sale_id", String(args.sale_id)) if (args.published != null) query.append("published", String(args.published)) if (args.artwork_id != null) query.append("artwork_id", String(args.artwork_id)) if (args.sort != null) query.append("sort", String(args.sort)) const url = `${baseUrl.replace(/\/+$/, '')}/api/sale_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 };