export type ContactEmailJson = {email?: string | undefined, email_type?: string | undefined}; export type ContactFamilyJson = {first_name?: string | undefined, last_name?: string | undefined, relationship?: string | undefined}; export type ContactAddressJson = {address_type?: string | undefined, city?: string | undefined, country?: string | undefined, state?: string | undefined, street?: string | undefined, street2?: string | undefined, zip?: string | undefined}; export type ContactPhoneJson = {number?: string | undefined, phone_type?: string | undefined}; export type ContactSamlJson = {saml_enabled?: boolean | undefined, saml_user_id?: string | undefined}; export type ContactViewSetOverrideJson = {entity_id?: number | undefined, group_id?: number | undefined, view_set_id?: number | undefined}; export type ContactJson = {birthday?: string | undefined, defaultViewSetId?: string | undefined, emails?: Array | undefined, employer?: string | undefined, entityAffiliationIds?: Array | undefined, externalUserId?: string | undefined, familyMembers?: Array | undefined, firstName?: string | undefined, groupAffiliationIds?: Array | undefined, id?: number | undefined, lastName?: string | undefined, loginEmail?: string | undefined, mailingAddresses?: Array | undefined, occupation?: string | undefined, phoneNumbers?: Array | undefined, portalAccessStatus?: string | undefined, samlSettings?: ContactSamlJson | undefined, ssn?: string | undefined, suffix?: string | undefined, team?: number | undefined, title?: string | undefined, twoFactorExempt?: boolean | undefined, viewSetOverrides?: Array | undefined}; export type CreateApiContactsArgs = {'Addepar-Firm': string, body: ContactJson}; export type CreateApiContactsOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Contact * * POST /contacts */ export const createApiContacts = async (args: CreateApiContactsArgs, options?: CreateApiContactsOptions) => { const {baseUrl = "https://examplefirm.addepar.com/api/v1", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/vnd.api+json") headers.set('accept', "application/vnd.api+json") if (args['Addepar-Firm'] != null) headers.set("Addepar-Firm", String(args['Addepar-Firm'])) if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/contacts${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 (await res.json()) as unknown };