export type JTLDataContractsKeysArtikelKey = string; export type JTLDataContractsKeysVorlagenSetKey = string; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateOverallComponentPostingsInventoryAccountingDataRequirements = 0 | 1; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateShelfLifeEndDateGenerationMode = 0 | 1 | 2; export type JTLPpsCoreContractsKeysOperationKey = string; export type JTLDataContractsKeysMassEinheitKey = string; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateComponentPostingsInventoryAccountingDataRequirements = 0 | 1 | 2; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateBillOfMaterialsItemInput = {itemId?: JTLDataContractsKeysArtikelKey | undefined, quantity?: number | undefined, measurementUnitId?: JTLDataContractsKeysMassEinheitKey | undefined, componentPostingsShelfLifeEndDateRequirements?: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateComponentPostingsInventoryAccountingDataRequirements | undefined, componentPostingsBatchNumberRequirements?: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateComponentPostingsInventoryAccountingDataRequirements | undefined}; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateBillOfMaterialsOperationInput = {operationId?: JTLPpsCoreContractsKeysOperationKey | undefined, items?: Array | undefined}; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateBillOfMaterialsInput = {name?: string | undefined, description?: string | undefined, componentPostingsShelfLifeEndDateRequirements?: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateOverallComponentPostingsInventoryAccountingDataRequirements | undefined, componentPostingsBatchNumberRequirements?: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateOverallComponentPostingsInventoryAccountingDataRequirements | undefined, shelfLifeEndDateGenerationMode?: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateShelfLifeEndDateGenerationMode | undefined, additionalShelfLifeEndDateTime?: unknown | undefined, operations?: Array | undefined}; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateLotSizeInput = {lotSize?: number | undefined}; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateProductionItemInput = {itemId?: JTLDataContractsKeysArtikelKey | undefined, isCustomized?: boolean | undefined, lotLabelTemplateId?: JTLDataContractsKeysVorlagenSetKey | undefined, singleItemLabelTemplateId?: JTLDataContractsKeysVorlagenSetKey | undefined, billsOfMaterials?: Array | undefined, lotSizes?: Array | undefined}; export type JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateProductionItemCommandRequest = {input?: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateProductionItemInput | undefined}; export type CreateApiV2ProductionItemsCreateArgs = {'x-tenant-id': string, 'x-runas'?: string | undefined, 'x-companyid'?: string | undefined, body: JTLPPSProductionItemsPublicApiDataTransferObjectsV2CreateCreateProductionItemCommandRequest}; export type CreateApiV2ProductionItemsCreateOptions = {baseUrl?: string | undefined, oauth2AuthorizationCode?: string | undefined, fetch?: typeof fetch | undefined}; /** * Creates a new production item, including its bills of materials with their components. * * POST /v2/production-items/create * * Also accepts auth: oauth2-client-credentials */ export const createApiV2ProductionItemsCreate = async (args: CreateApiV2ProductionItemsCreateArgs, options?: CreateApiV2ProductionItemsCreateOptions) => { 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/production-items/create${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 };