export type GetApi30ListsListIdSurveysSurveyIdArgs = {list_id: string, survey_id: string}; export type GetApi30ListsListIdSurveysSurveyIdOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get survey * * GET /3.0/lists/{list_id}/surveys/{survey_id} * * Also accepts auth: oauth2 */ export const getApi30ListsListIdSurveysSurveyId = async (args: GetApi30ListsListIdSurveysSurveyIdArgs, options?: GetApi30ListsListIdSurveysSurveyIdOptions) => { const {baseUrl = "https://api.mailchimp.com", fetch: fetchFn = fetch, bearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() 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: "GET", headers}) 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 };