export type GetApiPersonsArgs = {id?: Array | undefined, name?: string | undefined, email?: string | undefined, search?: string | undefined}; export type GetApiPersonsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List persons * * GET /persons */ export const getApiPersons = async (args: GetApiPersonsArgs, options?: GetApiPersonsOptions) => { 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)) const url = `${baseUrl.replace(/\/+$/, '')}/persons${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() };