export type UpdateApiReviewsSiteidReviewidArgs = {siteid: number, reviewid: string, xml?: boolean | undefined, body: {token: string, followup?: string | undefined, cancel?: number | undefined}}; export type UpdateApiReviewsSiteidReviewidOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Updates or cancels a review. * * PUT /reviews/{siteid}/{reviewid} */ export const updateApiReviewsSiteidReviewid = async (args: UpdateApiReviewsSiteidReviewidArgs, options?: UpdateApiReviewsSiteidReviewidOptions) => { const {baseUrl = "https://api.shopperapproved.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") if (args.xml != null) query.append("xml", String(args.xml)) const url = `${baseUrl.replace(/\/+$/, '')}/reviews/${encodeURIComponent(String(args.siteid))}/${encodeURIComponent(String(args.reviewid))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };