export type GetApiProductsReviewsSiteidArgs = {siteid: number, token: string, asArray?: boolean | undefined, limit?: number | undefined, page?: number | undefined, from?: string | undefined, to?: string | undefined, sort?: ('newest' | 'oldest' | 'highest' | 'lowest') | undefined, removed?: (0 | 1) | undefined, xml?: boolean | undefined}; export type GetApiProductsReviewsSiteidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetches product reviews. * * GET /products/reviews/{siteid} */ export const getApiProductsReviewsSiteid = async (args: GetApiProductsReviewsSiteidArgs, options?: GetApiProductsReviewsSiteidOptions) => { 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.asArray != null) query.append("asArray", String(args.asArray)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.page != null) query.append("page", String(args.page)) if (args.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.removed != null) query.append("removed", String(args.removed)) if (args.xml != null) query.append("xml", String(args.xml)) const url = `${baseUrl.replace(/\/+$/, '')}/products/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 };