export type DeleteApiApiV2MacrosDestroyManyArgs = {ids: Array}; export type DeleteApiApiV2MacrosDestroyManyOptions = {baseUrl?: string | undefined, apiTokenAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Bulk Delete Macros * * DELETE /api/v2/macros/destroy_many */ export const deleteApiApiV2MacrosDestroyMany = async (args: DeleteApiApiV2MacrosDestroyManyArgs, options?: DeleteApiApiV2MacrosDestroyManyOptions) => { const {baseUrl = "https://example.zendesk.com", fetch: fetchFn = fetch, apiTokenAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.ids ?? []) query.append("ids", String(item)) if (apiTokenAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${apiTokenAuth.username}:${apiTokenAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/macros/destroy_many${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };