export type CreateApiV5AutocompleteArgs = {body: {field?: ('company' | 'country' | 'industry' | 'location' | 'major' | 'region' | 'role' | 'school' | 'sub_role' | 'skill' | 'title') | undefined, text?: string | undefined, size?: number | undefined, titlecase?: boolean | undefined, pretty?: boolean | undefined}}; export type CreateApiV5AutocompleteOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * /autocomplete * * POST /v5/autocomplete */ export const createApiV5Autocomplete = async (args: CreateApiV5AutocompleteArgs, options?: CreateApiV5AutocompleteOptions) => { const {baseUrl = "https://api.peopledatalabs.com", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIKeyHeader !== undefined) headers.set("X-API-Key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/v5/autocomplete${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };