export type JTLDataContractsKeysArtikelKey = string; export type JTLDataContractsKeysLieferantKey = string; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateSupplierPrice = {fromQuantity?: number | undefined, netPrice?: number | undefined, usePercentageDiscount?: boolean | undefined, percentageDiscount?: number | undefined}; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateItemSupplier = {supplierId?: JTLDataContractsKeysLieferantKey | undefined, supplierItemName?: string | undefined, supplierItemNumber?: string | undefined, stockLevel?: number | undefined, netPurchasePrice?: number | undefined, minimumPurchaseQuantity?: number | undefined, deliveryTimeInDays?: number | undefined, isDropshippingActive?: boolean | undefined, packageUnitDescription?: string | undefined, packageUnitQuantity?: number | undefined, notes?: string | undefined, vatRate?: number | undefined, useSupplierDeliveryTime?: boolean | undefined, includeSupplierStock?: boolean | undefined, purchaseInterval?: number | undefined, scalePrices?: Array | undefined}; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsAddItemSupplierCommandRequest = {itemId?: JTLDataContractsKeysArtikelKey | undefined, itemSupplier?: JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateItemSupplier | undefined}; export type CreateApiV2ItemdetailsSuppliersAddArgs = {'x-tenant-id': string, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined, body: JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsAddItemSupplierCommandRequest}; export type CreateApiV2ItemdetailsSuppliersAddOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adds supplier information to an existing regular item. This command allows the association of suppliers with the item, including details such as purchase prices, delivery times, and order intervals. * * POST /v2/itemdetails/suppliers/add * * Also accepts auth: oauth2-client-credentials */ export const createApiV2ItemdetailsSuppliersAdd = async (args: CreateApiV2ItemdetailsSuppliersAddArgs, options?: CreateApiV2ItemdetailsSuppliersAddOptions) => { const {baseUrl = "https://scx-sbx.api.jtl-software.com", fetch: fetchFn = fetch, oauth2AuthorizationCode} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['x-tenant-id'] != null) headers.set("x-tenant-id", String(args['x-tenant-id'])) if (args['x-runas'] != null) headers.set("x-runas", String(args['x-runas'])) if (args['x-companyid'] != null) headers.set("x-companyid", String(args['x-companyid'])) if (oauth2AuthorizationCode !== undefined) headers.set('authorization', `Bearer ${oauth2AuthorizationCode}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/itemdetails/suppliers/add${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 };