export type CompanyRelationsDto = {companyId: string, email?: string | undefined, status?: string | undefined, position?: string | undefined}; export type AddCompaniesRelationsDto = {companies: Array}; export type CreateApiApiV1ContactsContactContactIdCompaniesArgs = {contactId: string, body: AddCompaniesRelationsDto}; export type CreateApiApiV1ContactsContactContactIdCompaniesOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; /** * Add companies to contact * * POST /api/v1/contacts/contact/{contactId}/companies */ export const createApiApiV1ContactsContactContactIdCompanies = async (args: CreateApiApiV1ContactsContactContactIdCompaniesArgs, options?: CreateApiApiV1ContactsContactContactIdCompaniesOptions) => { const {baseUrl = "https://api.getprospect.com", fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("apiKey", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/contacts/contact/${encodeURIComponent(String(args.contactId))}/companies${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 };