export type GetApiReviewsSiteidArgs = {siteid: number, token: string, from?: string | undefined, to?: string | undefined, rating?: string | undefined, sort?: ('newest' | 'oldest' | 'highest' | 'lowest' | 'featured') | undefined, limit?: number | undefined, full_name?: (0 | 1) | undefined, page?: number | undefined, removed?: (0 | 1) | undefined, test?: boolean | undefined, xml?: boolean | undefined}; export type GetApiReviewsSiteidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Fetch a number of reviews * * GET /reviews/{siteid} */ export const getApiReviewsSiteid = async (args: GetApiReviewsSiteidArgs, options?: GetApiReviewsSiteidOptions) => { 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.from != null) query.append("from", String(args.from)) if (args.to != null) query.append("to", String(args.to)) if (args.rating != null) query.append("rating", String(args.rating)) if (args.sort != null) query.append("sort", String(args.sort)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.full_name != null) query.append("full_name", String(args.full_name)) if (args.page != null) query.append("page", String(args.page)) if (args.removed != null) query.append("removed", String(args.removed)) if (args.test != null) query.append("test", String(args.test)) if (args.xml != null) query.append("xml", String(args.xml)) const url = `${baseUrl.replace(/\/+$/, '')}/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 };