export type CreateApiApiV2CustomersArgs = {body: {customerType?: ('person' | 'company' | null) | undefined, firstname?: (string | null) | undefined, lastname?: (string | null) | undefined, name?: (string | null) | undefined, title?: (string | null) | undefined, birthdate?: (string | null) | undefined, number?: (string | null) | undefined, deviatingCustomerNumber?: (string | null) | undefined, salutation?: ('mr' | 'mrs' | 'company' | 'other' | null) | undefined, salutationPhrase?: (string | null) | undefined, department?: (string | null) | undefined, subDepartment?: (string | null) | undefined, project?: ({id?: string | undefined}) | undefined, contactDetails?: ({phone?: (string | null) | undefined, mobile?: (string | null) | undefined, fax?: (string | null) | undefined, email?: (string | null) | undefined, website?: (string | null) | undefined, additionalData?: (Array<{label: string, value: string | null} | null>) | undefined}) | undefined, accountManager?: ({id: string} | null) | undefined, salesManager?: ({id: string} | null) | undefined, isLead?: boolean | undefined, groups?: (Array | null) | undefined, customFields?: (Array<{id: number, value: string | null}>) | undefined, financials?: ({tax?: ({taxation?: ('domestic' | 'eu-delivery' | 'export' | 'free') | undefined, taxDisplay?: ('automatically' | 'always-net' | 'always-gross') | undefined, useDeliveryThreshold?: boolean | undefined, taxNumber?: (string | null) | undefined, vatId?: (string | null) | undefined}) | undefined, paymentTerms?: ({fixedPaymentTerms?: boolean | undefined, paymentTargetDays?: (number | null) | undefined, paymentTargetDiscount?: number | undefined, paymentTargetDiscountDays?: (number | null) | undefined}) | undefined, paymentMethod?: ({id: string} | null) | undefined, subscriptionPaymentMethod?: ('invoice' | 'direct-debit' | null) | undefined, customsInformation?: (string | null) | undefined, creditLimit?: number | undefined, defaultCurrency?: string | undefined}) | undefined, primaryBankAccount?: ({bankName?: string | undefined, owner?: string | undefined, iban?: string | undefined, bic?: string | undefined, sepa?: ({companySepa?: boolean | undefined, mandateReference?: string | undefined, mandateReferenceChange?: boolean | undefined, mandateReferenceDate?: string | undefined, usage?: ('recurring' | 'single') | undefined, initial?: boolean | undefined, remark?: string | undefined}) | undefined}) | undefined, documentDelivery?: ({autoCreateDocuments?: ('both' | 'delivery_note' | 'invoice') | undefined, invoiceAlwaysPaper?: boolean | undefined, amountInvoicePrints?: (number | null) | undefined, preferFax?: boolean | undefined}) | undefined, shipping?: ({freeShipping?: boolean | undefined, trackingMailBan?: boolean | undefined, deliveryBan?: boolean | undefined, freeShippingFrom?: number | undefined, deliveryBanReason?: (string | null) | undefined, deliveryBanDate?: (string | null) | undefined, shippingMethod?: ({id: string} | null) | undefined}) | undefined}}; export type CreateApiApiV2CustomersOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create customer * * POST /api/v2/customers */ export const createApiApiV2Customers = async (args: CreateApiApiV2CustomersArgs, options?: CreateApiApiV2CustomersOptions) => { const {baseUrl = "https://xentral.xentral.biz", fetch: fetchFn = fetch, BearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/html") if (BearerAuth !== undefined) headers.set('authorization', `Bearer ${BearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/customers${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 res.text() };