export type GetApi30ListsListIdSurveysArgs = {list_id: string}; export type GetApi30ListsListIdSurveysOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get information about all surveys for a list * * GET /3.0/lists/{list_id}/surveys * * Also accepts auth: oauth2 */ export const getApi30ListsListIdSurveys = async (args: GetApi30ListsListIdSurveysArgs, options?: GetApi30ListsListIdSurveysOptions) => { 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${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 };