export type GetApiUsersArgs = {id?: Array | undefined, name?: string | undefined, email?: string | undefined, search?: string | undefined, limit?: number | undefined, offset?: number | undefined, order_by?: Array | undefined, onlyEnabled?: boolean | undefined}; export type GetApiUsersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List users * * GET /users */ export const getApiUsers = async (args: GetApiUsersArgs, options?: GetApiUsersOptions) => { 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.name != null) query.append("name", String(args.name)) if (args.email != null) query.append("email", String(args.email)) if (args.search != null) query.append("search", String(args.search)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.offset != null) query.append("offset", String(args.offset)) for (const item of args.order_by ?? []) query.append("order_by", String(item)) if (args.onlyEnabled != null) query.append("onlyEnabled", String(args.onlyEnabled)) const url = `${baseUrl.replace(/\/+$/, '')}/users${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() };