export type GetApiApiSalesArgs = {offset?: number | undefined, size?: string | undefined, cursor?: string | undefined, live?: boolean | undefined, is_auction?: boolean | undefined, published?: boolean | undefined, sort?: ('id' | '-id' | 'name' | '-name' | 'created_at' | '-created_at' | 'start_at' | '-start_at' | 'end_at' | '-end_at' | 'eligible_sale_artworks_count' | '-eligible_sale_artworks_count' | 'timely_at' | '-timely_at' | 'timely_at,name' | '-timely_at,name' | 'is_artsy_licensed,timely_at,name' | '-is_artsy_licensed,timely_at,name') | undefined}; export type GetApiApiSalesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Retrieve sales. * * GET /api/sales */ export const getApiApiSales = async (args: GetApiApiSalesArgs, options: GetApiApiSalesOptions) => { 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.live != null) query.append("live", String(args.live)) if (args.is_auction != null) query.append("is_auction", String(args.is_auction)) if (args.published != null) query.append("published", String(args.published)) if (args.sort != null) query.append("sort", String(args.sort)) const url = `${baseUrl.replace(/\/+$/, '')}/api/sales${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 };