export type PatchApi30ListsListIdSurveysSurveyIdArgs = {list_id: string, survey_id: string, body: {title?: string | undefined, is_piped_to_inbox?: boolean | undefined, sections?: (Array<{id?: string | undefined, type: 'introduction' | 'context' | 'question', text?: string | undefined, options?: Record | undefined, question?: ({id?: string | undefined, query: string, type: 'pickOne' | 'pickMany' | 'range' | 'text' | 'email' | 'contactInformation' | 'dropdown', is_required?: boolean | undefined, has_other?: boolean | undefined, other_label?: string | undefined, range_low_label?: string | undefined, range_high_label?: string | undefined, range_low_value?: number | undefined, range_high_value?: number | undefined, range_presentation?: string | undefined, placeholder_label?: string | undefined, subscribe_checkbox_enabled?: boolean | undefined, subscribe_checkbox_label?: string | undefined, should_auto_tag?: boolean | undefined, options?: Array<{label: string, value: string}> | undefined, merge_field?: Record | undefined}) | undefined}>) | undefined}}; export type PatchApi30ListsListIdSurveysSurveyIdOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update survey * * PATCH /3.0/lists/{list_id}/surveys/{survey_id} * * Also accepts auth: oauth2 */ export const patchApi30ListsListIdSurveysSurveyId = async (args: PatchApi30ListsListIdSurveysSurveyIdArgs, options?: PatchApi30ListsListIdSurveysSurveyIdOptions) => { const {baseUrl = "https://api.mailchimp.com", fetch: fetchFn = fetch, bearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (bearerToken !== undefined) headers.set('authorization', `Bearer ${bearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/3.0/lists/${encodeURIComponent(String(args.list_id))}/surveys/${encodeURIComponent(String(args.survey_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 (await res.json()) as unknown };