export type ReviewReply = {comment: string, sendNotification?: boolean | undefined}; export type CreateApiReviewsReviewIdReplyArgs = {reviewId: string, body: ReviewReply}; export type CreateApiReviewsReviewIdReplyOptions = {baseUrl: string, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Save a review reply * * POST /reviews/{reviewId}/reply */ export const createApiReviewsReviewIdReply = async (args: CreateApiReviewsReviewIdReplyArgs, options: CreateApiReviewsReviewIdReplyOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/reviews/${encodeURIComponent(String(args.reviewId))}/reply${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };