export type GetApiAggregatesProductsSiteidArgs = {siteid: number, token: string, by_match_key?: boolean | undefined, asArray?: boolean | undefined, siteOnly?: boolean | undefined, xml?: boolean | undefined, fastmode?: boolean | undefined}; export type GetApiAggregatesProductsSiteidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetch aggregate product statistics for your site * * GET /aggregates/products/{siteid} */ export const getApiAggregatesProductsSiteid = async (args: GetApiAggregatesProductsSiteidArgs, options?: GetApiAggregatesProductsSiteidOptions) => { const {baseUrl = "https://api.shopperapproved.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.token != null) query.append("token", String(args.token)) if (args.by_match_key != null) query.append("by_match_key", String(args.by_match_key)) if (args.asArray != null) query.append("asArray", String(args.asArray)) if (args.siteOnly != null) query.append("siteOnly", String(args.siteOnly)) if (args.xml != null) query.append("xml", String(args.xml)) if (args.fastmode != null) query.append("fastmode", String(args.fastmode)) const url = `${baseUrl.replace(/\/+$/, '')}/aggregates/products/${encodeURIComponent(String(args.siteid))}${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 };