export type GetApiCustomersExportArgs = {format?: ('csv' | 'xls' | 'xlsx') | undefined, query?: string | undefined, name?: string | undefined, email?: string | undefined, phone?: string | undefined, customer_group_id?: number | undefined, status?: number | undefined, channel_id?: number | undefined, created_at_from?: string | undefined, created_at_to?: string | undefined}; export type GetApiCustomersExportOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export customers as csv, xls or xlsx * * GET /customers/export */ export const getApiCustomersExport = async (args: GetApiCustomersExportArgs, options?: GetApiCustomersExportOptions) => { 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.query != null) query.append("query", String(args.query)) if (args.name != null) query.append("name", String(args.name)) if (args.email != null) query.append("email", String(args.email)) if (args.phone != null) query.append("phone", String(args.phone)) if (args.customer_group_id != null) query.append("customer_group_id", String(args.customer_group_id)) if (args.status != null) query.append("status", String(args.status)) if (args.channel_id != null) query.append("channel_id", String(args.channel_id)) if (args.created_at_from != null) query.append("created_at_from", String(args.created_at_from)) if (args.created_at_to != null) query.append("created_at_to", String(args.created_at_to)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/customers/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() };