export type GetApiAccountsArgs = {id?: Array | undefined, details?: boolean | undefined, search?: string | undefined, name?: string | undefined, creation_after?: string | undefined, creation_before?: string | undefined, min_size?: number | undefined, max_size?: number | undefined, domain?: Array | undefined, tag?: Array | undefined, 'tag.name'?: Array | undefined, 'address.country'?: Array | undefined, 'address.city'?: Array | undefined, 'address.state_region'?: Array | undefined, hotness?: number | undefined, offset?: number | undefined, custom?: string | undefined, order_by?: Array | undefined, q?: string | undefined, limit?: number | undefined, export?: string | undefined}; export type GetApiAccountsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List accounts * * GET /accounts */ export const getApiAccounts = async (args: GetApiAccountsArgs, options?: GetApiAccountsOptions) => { 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.details != null) query.append("details", String(args.details)) if (args.search != null) query.append("search", String(args.search)) if (args.name != null) query.append("name", String(args.name)) if (args.creation_after != null) query.append("creation_after", String(args.creation_after)) if (args.creation_before != null) query.append("creation_before", String(args.creation_before)) if (args.min_size != null) query.append("min_size", String(args.min_size)) if (args.max_size != null) query.append("max_size", String(args.max_size)) for (const item of args.domain ?? []) query.append("domain", String(item)) for (const item of args.tag ?? []) query.append("tag", String(item)) for (const item of args['tag.name'] ?? []) query.append("tag.name", String(item)) for (const item of args['address.country'] ?? []) query.append("address.country", String(item)) for (const item of args['address.city'] ?? []) query.append("address.city", String(item)) for (const item of args['address.state_region'] ?? []) query.append("address.state_region", String(item)) if (args.hotness != null) query.append("hotness", String(args.hotness)) if (args.offset != null) query.append("offset", String(args.offset)) if (args.custom != null) query.append("custom", String(args.custom)) for (const item of args.order_by ?? []) query.append("order_by", String(item)) if (args.q != null) query.append("q", String(args.q)) if (args.limit != null) query.append("limit", String(args.limit)) if (args.export != null) query.append("export", String(args.export)) const url = `${baseUrl.replace(/\/+$/, '')}/accounts${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() };