export type GetApiAggregatesReviewsSiteidArgs = {siteid: number, token: string, xml?: boolean | undefined}; export type GetApiAggregatesReviewsSiteidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetch aggregate statistics for your site * * GET /aggregates/reviews/{siteid} */ export const getApiAggregatesReviewsSiteid = async (args: GetApiAggregatesReviewsSiteidArgs, options?: GetApiAggregatesReviewsSiteidOptions) => { 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.xml != null) query.append("xml", String(args.xml)) const url = `${baseUrl.replace(/\/+$/, '')}/aggregates/reviews/${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 };