export type CreateApiApiV2CustomersCustomerIdAddressesArgs = {customerId: string, body: {type: 'masterdata', street: string, addressSupplement?: (string | null) | undefined, zip?: (string | null) | undefined, city: string, country: string, state?: (string | null) | undefined} | {type: 'billingaddress', name: string, salutation?: ('mr' | 'mrs' | 'company' | 'other' | null) | undefined, street: string, addressSupplement?: (string | null) | undefined, zip?: (string | null) | undefined, city: string, country: string, state?: (string | null) | undefined, department?: (string | null) | undefined, subDepartment?: (string | null) | undefined, contactDetails?: ({phone?: (string | null) | undefined, email?: (string | null) | undefined, gln?: (unknown | null) | undefined} | null) | undefined} | {type: 'deliveryaddress', name: string, salutation?: ('mr' | 'mrs' | 'company' | 'other' | null) | undefined, street: string, addressSupplement?: (string | null) | undefined, zip?: (string | null) | undefined, city: string, country: string, state?: (string | null) | undefined, department?: (string | null) | undefined, subDepartment?: (string | null) | undefined, contactDetails?: ({phone?: (string | null) | undefined, email?: (string | null) | undefined, gln?: (unknown | null) | undefined}) | undefined, deliveryDetails?: ({defaultDeliveryAddress?: boolean | undefined, termsOfDelivery?: (string | null) | undefined, vatId?: (string | null) | undefined, taxType?: ('domestic' | 'eu-delivery' | 'export' | 'free') | undefined, internalComment?: (string | null) | undefined, note?: (string | null) | undefined} | null) | undefined}}; export type CreateApiApiV2CustomersCustomerIdAddressesOptions = {baseUrl?: string | undefined, BearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create address * * POST /api/v2/customers/{customerId}/addresses */ export const createApiApiV2CustomersCustomerIdAddresses = async (args: CreateApiApiV2CustomersCustomerIdAddressesArgs, options?: CreateApiApiV2CustomersCustomerIdAddressesOptions) => { 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/${encodeURIComponent(String(args.customerId))}/addresses${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() };