export type GetApiV1QuestionnaireIdDownloadAnswersOptions = {baseUrl?: string | undefined, Authorization?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get questionnaire csv * * GET /v1/questionnaire/{id}/download-answers */ export const getApiV1QuestionnaireIdDownloadAnswers = async (options?: GetApiV1QuestionnaireIdDownloadAnswersOptions) => { const {baseUrl = "https://api.resourcewatch.org", fetch: fetchFn = fetch, Authorization} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (Authorization !== undefined) headers.set('authorization', `Bearer ${Authorization}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/questionnaire/${encodeURIComponent(String(args.id))}/download-answers${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 res.text() };