export type GetApiCmsPagesExportArgs = {format?: ('csv' | 'xls' | 'xlsx') | undefined, id?: number | undefined, page_title?: string | undefined, url_key?: string | undefined, channel?: number | undefined, locale?: string | undefined}; export type GetApiCmsPagesExportOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export CMS pages as csv, xls or xlsx * * GET /cms/pages/export */ export const getApiCmsPagesExport = async (args: GetApiCmsPagesExportArgs, options?: GetApiCmsPagesExportOptions) => { const {baseUrl = "http://localhost:8000/api/admin", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.format != null) query.append("format", String(args.format)) if (args.id != null) query.append("id", String(args.id)) if (args.page_title != null) query.append("page_title", String(args.page_title)) if (args.url_key != null) query.append("url_key", String(args.url_key)) if (args.channel != null) query.append("channel", String(args.channel)) if (args.locale != null) query.append("locale", String(args.locale)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/cms/pages/export${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() };