export type GetApiFundableCompanySearchArgs = {name?: string | undefined, domain?: string | undefined, linkedin?: string | undefined, crunchbase?: string | undefined}; export type GetApiFundableCompanySearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search for company id using fuzzy match or other identifiers * * GET /fundable/company/search */ export const getApiFundableCompanySearch = async (args: GetApiFundableCompanySearchArgs, options?: GetApiFundableCompanySearchOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.name != null) query.append("name", String(args.name)) if (args.domain != null) query.append("domain", String(args.domain)) if (args.linkedin != null) query.append("linkedin", String(args.linkedin)) if (args.crunchbase != null) query.append("crunchbase", String(args.crunchbase)) const url = `${baseUrl.replace(/\/+$/, '')}/fundable/company/search${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 undefined };