export type GetApiV1UsersArgs = {filter?: Array | undefined, pageSize?: number | undefined, scrollId?: string | undefined, sort?: string | undefined}; export type GetApiV1UsersOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Get users * * GET /v1/users */ export const getApiV1Users = async (args: GetApiV1UsersArgs, options?: GetApiV1UsersOptions) => { const {baseUrl = "https://app.aptrinsic.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "*/*") for (const item of args.filter ?? []) query.append("filter", String(item)) if (args.pageSize != null) query.append("pageSize", String(args.pageSize)) if (args.scrollId != null) query.append("scrollId", String(args.scrollId)) if (args.sort != null) query.append("sort", String(args.sort)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/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() };