export type JTLDataContractsKeysArtikelKey = string; export type JTLDataContractsKeysVariationKey = string; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateDescription = {languageIso?: string | undefined, name?: string | undefined}; export type JTLDataContractsKeysVariationWertKey = string; export type JTLDataContractsKeysKundenGruppeKey = string; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateCustomerGroupSurcharge = {customerGroupId?: JTLDataContractsKeysKundenGruppeKey | undefined, surcharge?: number | undefined, isActive?: boolean | undefined}; export type JTLWawiRestContractsModelsSalesChannelId = string; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateSalesChannelSurcharge = {salesChannelId?: JTLWawiRestContractsModelsSalesChannelId | undefined, surcharges?: Array | undefined}; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateVariationValueSurcharges = {defaultSurchargeNet?: number | undefined, customerGroupSurcharges?: Array | undefined, salesChannelSurcharges?: Array | undefined}; export type JTLDataContractsKeysBildKey = string; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateVariationValue = {variationValueId?: JTLDataContractsKeysVariationWertKey | undefined, itemNumber?: string | undefined, gTIN?: string | undefined, weightOffset?: number | undefined, descriptions?: Array | undefined, surcharges?: JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateVariationValueSurcharges | undefined, position?: number | undefined, image?: JTLDataContractsKeysBildKey | undefined}; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsVariationType = 0 | 1 | 2 | 3 | 4 | 5 | 6; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateVariation = {variationId?: JTLDataContractsKeysVariationKey | undefined, position?: number | undefined, descriptions?: Array | undefined, values?: Array | undefined, variationType?: JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsVariationType | undefined}; export type JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsAddItemVariationCommandRequest = {itemId?: JTLDataContractsKeysArtikelKey | undefined, variation?: JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsCreateVariation | undefined}; export type CreateApiV2ItemdetailsVariationsAddArgs = {'x-tenant-id': string, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined, body: JTLWawiItemPublicApiDataTransferObjectsV2ItemdetailsAddItemVariationCommandRequest}; export type CreateApiV2ItemdetailsVariationsAddOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Adds a new variation (e.g., color, size) to an existing item. Variations allow customers to select different product options. * * POST /v2/itemdetails/variations/add * * Also accepts auth: oauth2-client-credentials */ export const createApiV2ItemdetailsVariationsAdd = async (args: CreateApiV2ItemdetailsVariationsAddArgs, options?: CreateApiV2ItemdetailsVariationsAddOptions) => { 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/variations/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 };