export type GetApiContactsImportDownloadContactImportArgs = {contactImport: number}; export type GetApiContactsImportDownloadContactImportOptions = {baseUrl?: string | undefined, apiAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Download contact import list as CSV * * GET /contacts/import/download/{contactImport} */ export const getApiContactsImportDownloadContactImport = async (args: GetApiContactsImportDownloadContactImportArgs, options?: GetApiContactsImportDownloadContactImportOptions) => { const {baseUrl = "https://api.salesmessage.com/pub/v2.3", fetch: fetchFn = fetch, apiAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (apiAuth !== undefined) headers.set('authorization', `Bearer ${apiAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/contacts/import/download/${encodeURIComponent(String(args.contactImport))}${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 undefined };