export type CreateApiIcypeasApiEmailSearchArgs = {body: {firstname: string, lastname: string, domainOrCompany: string, custom?: Record | undefined}}; export type CreateApiIcypeasApiEmailSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Find a professional email address by providing a first name, last name, and domain or company name. Returns a search ID to poll for results via the Fetch Search Result endpoint. Async: status progresses NONE → SCHEDULED → IN_PROGRESS → DEBITED (found) or NOT_DEBITED (not found). * * POST /icypeas/api/email-search */ export const createApiIcypeasApiEmailSearch = async (args: CreateApiIcypeasApiEmailSearchArgs, options?: CreateApiIcypeasApiEmailSearchOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/icypeas/api/email-search${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 };