export type GetApiContactsArgs = {id?: Array | undefined, name?: string | undefined, email?: string | undefined, phone_number?: string | undefined, domain?: string | undefined, modification_after?: string | undefined, modification_before?: string | undefined, creation_after?: string | undefined, creation_before?: string | undefined, account?: Array | undefined, tag?: Array | undefined, 'tag.name'?: Array | undefined, 'position.role'?: Array | undefined, 'address.country'?: Array | undefined, 'address.state_region'?: Array | undefined, 'address.city'?: Array | undefined, includeArchived?: boolean | undefined, search?: string | undefined, type?: ('customer' | 'mycontacts') | undefined, limit?: number | undefined, offset?: number | undefined, custom?: string | undefined, order_by?: Array | undefined, export?: string | undefined, q?: string | undefined}; export type GetApiContactsOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * List contacts * * GET /contacts */ export const getApiContacts = async (args: GetApiContactsArgs, options?: GetApiContactsOptions) => { 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.phone_number != null) query.append("phone_number", String(args.phone_number)) if (args.domain != null) query.append("domain", String(args.domain)) if (args.modification_after != null) query.append("modification_after", String(args.modification_after)) if (args.modification_before != null) query.append("modification_before", String(args.modification_before)) 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)) for (const item of args.account ?? []) query.append("account", 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['position.role'] ?? []) query.append("position.role", String(item)) for (const item of args['address.country'] ?? []) query.append("address.country", String(item)) for (const item of args['address.state_region'] ?? []) query.append("address.state_region", String(item)) for (const item of args['address.city'] ?? []) query.append("address.city", String(item)) if (args.includeArchived != null) query.append("includeArchived", String(args.includeArchived)) if (args.search != null) query.append("search", String(args.search)) if (args.type != null) query.append("type", String(args.type)) if (args.limit != null) query.append("limit", String(args.limit)) 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.export != null) query.append("export", String(args.export)) if (args.q != null) query.append("q", String(args.q)) const url = `${baseUrl.replace(/\/+$/, '')}/contacts${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() };