export type Address = {streetAddress?: string | undefined, streetAddressLine2?: string | undefined, city?: string | undefined, postCode?: string | undefined, country: string}; export type ContactPerson = {contactPersonId?: number | undefined, name: string, email: string, phoneNumber?: string | undefined, address?: Address | undefined}; export type ContactNote = {author?: string | undefined, note?: string | undefined}; export type Attachment = {uuid?: string | undefined, filename?: string | undefined, identifier?: string | undefined, downloadUrl?: string | undefined, downloadUrlWithFikenNormalUserCredentials?: string | undefined, comment?: string | undefined, type?: ('invoice' | 'reminder' | 'unspecified' | 'ocr' | 'bank_statement') | undefined}; export type Contact = {contactId?: number | undefined, createdDate?: string | undefined, lastModifiedDate?: string | undefined, name: string, email?: string | undefined, organizationNumber?: string | undefined, customerNumber?: number | undefined, customerAccountCode?: string | undefined, phoneNumber?: string | undefined, memberNumber?: number | undefined, memberNumberString?: string | undefined, supplierNumber?: number | undefined, supplierAccountCode?: string | undefined, customer?: boolean | undefined, supplier?: boolean | undefined, bankAccountNumber?: string | undefined, contactPerson?: Array | undefined, notes?: Array | undefined, currency?: string | undefined, language?: (string | null) | undefined, inactive?: boolean | undefined, daysUntilInvoicingDueDate?: number | undefined, discount?: number | undefined, address?: Address | undefined, groups?: Array | undefined, documents?: Array | undefined}; export type CreateApiCompaniesCompanySlugContactsArgs = {body: Contact}; export type CreateApiCompaniesCompanySlugContactsOptions = {baseUrl?: string | undefined, fikenApiOauth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new contact. The Location response header returns the URL of the newly created contact. * * POST /companies/{companySlug}/contacts */ export const createApiCompaniesCompanySlugContacts = async (args: CreateApiCompaniesCompanySlugContactsArgs, options?: CreateApiCompaniesCompanySlugContactsOptions) => { const {baseUrl = "https://api.fiken.no/api/v2", fetch: fetchFn = fetch, fikenApiOauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (fikenApiOauth !== undefined) headers.set('authorization', `Bearer ${fikenApiOauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/companies/${encodeURIComponent(String(args.companySlug))}/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 undefined };