export type GetApiTasksArgs = {id?: Array | undefined, search?: string | undefined, assignees?: Array | undefined, type?: Array | undefined, account?: Array | undefined, order_by?: Array | undefined, limit?: number | undefined, offset?: number | undefined, export?: string | undefined, q?: string | undefined}; export type GetApiTasksOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List tasks * * GET /tasks */ export const getApiTasks = async (args: GetApiTasksArgs, options?: GetApiTasksOptions) => { const {baseUrl = "https://api.salesflare.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") for (const item of args.id ?? []) query.append("id", String(item)) if (args.search != null) query.append("search", String(args.search)) for (const item of args.assignees ?? []) query.append("assignees", String(item)) for (const item of args.type ?? []) query.append("type", String(item)) for (const item of args.account ?? []) query.append("account", String(item)) for (const item of args.order_by ?? []) query.append("order_by", String(item)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.export != null) query.append("export", String(args.export)) if (args.q != null) query.append("q", String(args.q)) const url = `${baseUrl.replace(/\/+$/, '')}/tasks${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.blob() };