export type Author = {profilePhotoUri?: string | undefined, type?: ('AUTHOR_TYPE_UNSPECIFIED' | 'REGULAR_USER' | 'LOCAL_GUIDE' | 'MERCHANT') | undefined, displayName?: string | undefined}; export type Answer = {name?: string | undefined, createTime?: unknown | undefined, upvoteCount?: number | undefined, text?: string | undefined, author?: Author | undefined, updateTime?: unknown | undefined}; export type UpsertAnswerRequest = {answer?: Answer | undefined}; export type CreateApiV1ParentAnswersUpsertArgs = {parent: string, body: UpsertAnswerRequest}; export type CreateApiV1ParentAnswersUpsertOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates an answer or updates the existing answer written by the user for the specified question. A user can only create one answer per question. * * POST /v1/{+parent}/answers:upsert */ export const createApiV1ParentAnswersUpsert = async (args: CreateApiV1ParentAnswersUpsertArgs, options?: CreateApiV1ParentAnswersUpsertOptions) => { const {baseUrl = "https://mybusinessqanda.googleapis.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v1/${encodeURIComponent(String(args['+parent']))}/answers:upsert${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 res.blob() };