import {z} from 'zod' export type EntityReference = {entityId?: string | undefined, entityName?: string | undefined}; export type OnlyId = {id?: string | undefined}; export type CustomAttribute = {attributeDefinitionId?: string | undefined, booleanValue?: boolean | undefined, dateValue?: number | undefined, entityId?: string | undefined, entityReferences?: Array | undefined, numberValue?: unknown | undefined, selectedValueId?: string | undefined, selectedValues?: Array | undefined, stringValue?: string | undefined}; export type RecordAddress = {city?: string | undefined, company?: string | undefined, company2?: string | undefined, countryCode?: ('AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AN' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CS' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DG' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EA' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'EU' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'IC' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'UNKNOWN' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XI' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW') | undefined, firstName?: string | undefined, globalLocationNumber?: string | undefined, lastName?: string | undefined, middleName?: string | undefined, phoneNumber?: string | undefined, postOfficeBoxCity?: string | undefined, postOfficeBoxNumber?: string | undefined, postOfficeBoxZipCode?: string | undefined, salutation?: ('COMPANY' | 'FAMILY' | 'MR' | 'MRS' | 'NO_SALUTATION') | undefined, state?: string | undefined, street1?: string | undefined, street2?: string | undefined, titleId?: string | undefined, zipcode?: string | undefined}; export type DropshippingDeliveryNoteFormTextBlockData = {recordComment?: string | undefined, recordFreeText?: string | undefined, recordOpening?: string | undefined}; export type BatchSerialNumber = {id?: string | undefined, version?: string | undefined, batchNumber?: string | undefined, createdDate?: number | undefined, expirationDate?: number | undefined, lastModifiedDate?: number | undefined, quantity?: unknown | undefined, serialNumbers?: Array | undefined}; export type CostCenterWithDistributionPercentage = {id?: string | undefined, version?: string | undefined, costCenterId: string, createdDate?: number | undefined, distributionPercentage: unknown, lastModifiedDate?: number | undefined}; export type ReductionAdditionItem = {position?: number | undefined, source?: ('ARTICLE' | 'ARTICLE_AND_CUSTOMER' | 'ARTICLE_CATEGORY' | 'ARTICLE_CATEGORY_AND_CUSTOMER') | undefined, specialPriceReduction?: boolean | undefined, title?: string | undefined, type?: ('ADDITIONAL_ABS' | 'ADDITION_PERCENT' | 'REDUCTION_ABS' | 'REDUCTION_PERCENT') | undefined, value?: unknown | undefined}; export type PurchaseOrderItem = {id?: string | undefined, version?: string | undefined, addPageBreakBefore?: boolean | undefined, articleId?: string | undefined, articleSupplySourceId?: string | undefined, batchSerialNumbers?: Array | undefined, blanketPurchaseOrderId?: string | undefined, blanketPurchaseOrderReleaseId?: string | undefined, costCenterItems?: Array | undefined, createdDate?: number | undefined, customAttributes?: Array | undefined, description?: string | undefined, descriptionFixed?: boolean | undefined, discountPercentage?: unknown | undefined, grossAmount?: unknown | undefined, grossAmountInCompanyCurrency?: unknown | undefined, groupName?: string | undefined, invoicedQuantity?: unknown | undefined, itemType?: ('DEFAULT' | 'FREE_TEXT' | 'SAMPLE' | 'SERVICE' | 'SERVICE_QUOTA') | undefined, lastModifiedDate?: number | undefined, manualQuantity?: boolean | undefined, manualUnitPrice?: boolean | undefined, netAmount?: unknown | undefined, netAmountForStatistics?: unknown | undefined, netAmountForStatisticsInCompanyCurrency?: unknown | undefined, netAmountInCompanyCurrency?: unknown | undefined, note?: string | undefined, parentItemId?: string | undefined, plannedDeliveryDate?: number | undefined, plannedShippingDate?: number | undefined, positionNumber?: number | undefined, purchaseOrderRequestOfferItemId?: string | undefined, quantity?: unknown | undefined, receivedQuantity?: unknown | undefined, reductionAdditionItems?: Array | undefined, salesOrderItemId?: string | undefined, servicePeriodFromDate?: number | undefined, servicePeriodToDate?: number | undefined, taxId?: string | undefined, title?: string | undefined, unitId?: string | undefined, unitPrice?: unknown | undefined, unitPriceInCompanyCurrency?: unknown | undefined}; export type EmailAddresses = {bccAddresses?: string | undefined, ccAddresses?: string | undefined, toAddresses?: string | undefined}; export type PurchaseOrderShippingCostItem = {id?: string | undefined, version?: string | undefined, articleId?: string | undefined, createdDate?: number | undefined, discountPercentage?: unknown | undefined, grossAmount?: unknown | undefined, grossAmountInCompanyCurrency?: unknown | undefined, lastModifiedDate?: number | undefined, manualUnitPrice?: boolean | undefined, netAmount?: unknown | undefined, netAmountInCompanyCurrency?: unknown | undefined, reductionAdditionItems?: Array | undefined, taxId?: string | undefined, unitPrice?: unknown | undefined, unitPriceInCompanyCurrency?: unknown | undefined}; export type PurchaseOrderStatusHistory = {status?: ('CANCELLED' | 'CLOSED' | 'CONFIRMED' | 'MANUALLY_CLOSED' | 'ORDER_DOCUMENTS_PRINTED' | 'ORDER_ENTRY_COMPLETED' | 'ORDER_ENTRY_IN_PROGRESS') | undefined, statusDate?: number | undefined, userId?: string | undefined}; export type PurchaseOrder = {id?: string | undefined, version?: string | undefined, advancePaymentStatus?: ('OPEN' | 'PAID') | undefined, blanketSalesOrderId?: string | undefined, commercialLanguage?: string | undefined, commercialLanguageCustomer?: string | undefined, commission?: string | undefined, confirmationNumber?: string | undefined, costCenterId?: string | undefined, createdDate?: number | undefined, creatorId?: string | undefined, currencyConversionDate?: number | undefined, currencyConversionLocked?: boolean | undefined, currencyConversionRate?: unknown | undefined, customAttributes?: Array | undefined, deliveryAddress?: RecordAddress | undefined, description?: string | undefined, disableRecordEmailingRule?: boolean | undefined, dropshippingDeliveryNoteFormTexts?: DropshippingDeliveryNoteFormTextBlockData | undefined, externalPurchaseOrderNumber?: string | undefined, formSettingsFromSalesChannel?: string | undefined, grossAmount?: unknown | undefined, grossAmountInCompanyCurrency?: unknown | undefined, grossAmountWithoutShippingCosts?: unknown | undefined, grossAmountWithoutShippingCostsInCompanyCurrency?: unknown | undefined, headerDiscount?: unknown | undefined, headerSurcharge?: unknown | undefined, includeCashDiscountInValuationPrice?: boolean | undefined, invoiceAddress?: RecordAddress | undefined, invoiced?: boolean | undefined, lastModifiedDate?: number | undefined, lastStatusChangeUserId?: string | undefined, mergedToPurchaseOrderId?: string | undefined, netAmount?: unknown | undefined, netAmountInCompanyCurrency?: unknown | undefined, netAmountWithoutShippingCosts?: unknown | undefined, netAmountWithoutShippingCostsInCompanyCurrency?: unknown | undefined, nonStandardTaxId?: string | undefined, note?: string | undefined, orderDate?: number | undefined, packageTrackingNumber?: string | undefined, packageTrackingUrl?: string | undefined, paid?: boolean | undefined, paymentMethodId?: string | undefined, plannedDeliveryDate?: number | undefined, plannedShippingDate?: number | undefined, purchaseOrderItems?: Array | undefined, purchaseOrderNumber?: string | undefined, purchaseOrderRequestId?: string | undefined, purchaseOrderType?: ('DROPSHIPPING' | 'NORMAL' | 'SALES_ORDER_COMMISSION') | undefined, received?: boolean | undefined, recipientCountryCode?: ('AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AN' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CS' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DG' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EA' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'EU' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'IC' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'UNKNOWN' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XI' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW') | undefined, recordAddress?: RecordAddress | undefined, recordComment?: string | undefined, recordCurrencyId: string, recordEmailAddresses?: EmailAddresses | undefined, recordFreeText?: string | undefined, recordOpening?: string | undefined, responsibleUserId?: string | undefined, salesOrderId?: string | undefined, senderCountryCode: 'AC' | 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AN' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CS' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DG' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EA' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'EU' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'IC' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KP' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TA' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'UNKNOWN' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'XI' | 'XK' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW', sentToRecipient?: boolean | undefined, servicePeriodFrom?: number | undefined, servicePeriodTo?: number | undefined, shipmentMethodId?: string | undefined, shippingCarrierId?: string | undefined, shippingCostItems?: Array | undefined, shippingNotificationDate?: number | undefined, status: 'CANCELLED' | 'CLOSED' | 'CONFIRMED' | 'MANUALLY_CLOSED' | 'ORDER_DOCUMENTS_PRINTED' | 'ORDER_ENTRY_COMPLETED' | 'ORDER_ENTRY_IN_PROGRESS', statusHistory?: Array | undefined, supplierHabitualExporterLetterOfIntentId?: string | undefined, supplierId: string, supplierQuotationNumber?: string | undefined, tags?: Array | undefined, termOfPaymentId?: string | undefined, vatAmount?: unknown | undefined, vatAmountInCompanyCurrency?: unknown | undefined, warehouseId?: string | undefined}; export type CreateApiPurchaseOrderArgs = {dryRun?: boolean | undefined, body: PurchaseOrder}; export type CreateApiPurchaseOrderOptions = {baseUrl: string, APIToken?: string | undefined, fetch?: typeof fetch | undefined}; export const entityReference = z.object({entityId: z.string().optional(), entityName: z.string().optional()}); export const onlyId = z.object({id: z.string().optional()}); export const customAttribute = z.object({attributeDefinitionId: z.string().optional(), booleanValue: z.boolean().optional(), dateValue: z.number().int().optional(), entityId: z.string().optional(), entityReferences: z.array(entityReference).optional(), numberValue: z.string().optional(), selectedValueId: z.string().optional(), selectedValues: z.array(onlyId).optional(), stringValue: z.string().optional()}); export const recordAddress = z.object({city: z.string().optional(), company: z.string().optional(), company2: z.string().optional(), countryCode: z.enum(["AC", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CS", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DG", "DJ", "DK", "DM", "DO", "DZ", "EA", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "EU", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "IC", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TA", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "UNKNOWN", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "XI", "XK", "YE", "YT", "ZA", "ZM", "ZW"]).optional(), firstName: z.string().optional(), globalLocationNumber: z.string().optional(), lastName: z.string().optional(), middleName: z.string().optional(), phoneNumber: z.string().optional(), postOfficeBoxCity: z.string().optional(), postOfficeBoxNumber: z.string().optional(), postOfficeBoxZipCode: z.string().optional(), salutation: z.enum(["COMPANY", "FAMILY", "MR", "MRS", "NO_SALUTATION"]).optional(), state: z.string().optional(), street1: z.string().optional(), street2: z.string().optional(), titleId: z.string().optional(), zipcode: z.string().optional()}); export const dropshippingDeliveryNoteFormTextBlockData = z.object({recordComment: z.string().optional(), recordFreeText: z.string().optional(), recordOpening: z.string().optional()}); export const batchSerialNumber = z.object({id: z.string().optional(), version: z.string().optional(), batchNumber: z.string().optional(), createdDate: z.number().int().optional(), expirationDate: z.number().int().optional(), lastModifiedDate: z.number().int().optional(), quantity: z.string().optional(), serialNumbers: z.array(z.string()).optional()}); export const costCenterWithDistributionPercentage = z.object({id: z.string().optional(), version: z.string().optional(), costCenterId: z.string(), createdDate: z.number().int().optional(), distributionPercentage: z.string(), lastModifiedDate: z.number().int().optional()}); export const reductionAdditionItem = z.object({position: z.number().int().optional(), source: z.enum(["ARTICLE", "ARTICLE_AND_CUSTOMER", "ARTICLE_CATEGORY", "ARTICLE_CATEGORY_AND_CUSTOMER"]).optional(), specialPriceReduction: z.boolean().optional(), title: z.string().optional(), type: z.enum(["ADDITIONAL_ABS", "ADDITION_PERCENT", "REDUCTION_ABS", "REDUCTION_PERCENT"]).optional(), value: z.string().optional()}); export const purchaseOrderItem = z.object({id: z.string().optional(), version: z.string().optional(), addPageBreakBefore: z.boolean().optional(), articleId: z.string().optional(), articleSupplySourceId: z.string().optional(), batchSerialNumbers: z.array(batchSerialNumber).optional(), blanketPurchaseOrderId: z.string().optional(), blanketPurchaseOrderReleaseId: z.string().optional(), costCenterItems: z.array(costCenterWithDistributionPercentage).optional(), createdDate: z.number().int().optional(), customAttributes: z.array(customAttribute).optional(), description: z.string().optional(), descriptionFixed: z.boolean().optional(), discountPercentage: z.string().optional(), grossAmount: z.string().optional(), grossAmountInCompanyCurrency: z.string().optional(), groupName: z.string().optional(), invoicedQuantity: z.string().optional(), itemType: z.enum(["DEFAULT", "FREE_TEXT", "SAMPLE", "SERVICE", "SERVICE_QUOTA"]).optional(), lastModifiedDate: z.number().int().optional(), manualQuantity: z.boolean().optional(), manualUnitPrice: z.boolean().optional(), netAmount: z.string().optional(), netAmountForStatistics: z.string().optional(), netAmountForStatisticsInCompanyCurrency: z.string().optional(), netAmountInCompanyCurrency: z.string().optional(), note: z.string().optional(), parentItemId: z.string().optional(), plannedDeliveryDate: z.number().int().optional(), plannedShippingDate: z.number().int().optional(), positionNumber: z.number().int().optional(), purchaseOrderRequestOfferItemId: z.string().optional(), quantity: z.string().optional(), receivedQuantity: z.string().optional(), reductionAdditionItems: z.array(reductionAdditionItem).optional(), salesOrderItemId: z.string().optional(), servicePeriodFromDate: z.number().int().optional(), servicePeriodToDate: z.number().int().optional(), taxId: z.string().optional(), title: z.string().optional(), unitId: z.string().optional(), unitPrice: z.string().optional(), unitPriceInCompanyCurrency: z.string().optional()}); export const emailAddresses = z.object({bccAddresses: z.string().optional(), ccAddresses: z.string().optional(), toAddresses: z.string().optional()}); export const purchaseOrderShippingCostItem = z.object({id: z.string().optional(), version: z.string().optional(), articleId: z.string().optional(), createdDate: z.number().int().optional(), discountPercentage: z.string().optional(), grossAmount: z.string().optional(), grossAmountInCompanyCurrency: z.string().optional(), lastModifiedDate: z.number().int().optional(), manualUnitPrice: z.boolean().optional(), netAmount: z.string().optional(), netAmountInCompanyCurrency: z.string().optional(), reductionAdditionItems: z.array(reductionAdditionItem).optional(), taxId: z.string().optional(), unitPrice: z.string().optional(), unitPriceInCompanyCurrency: z.string().optional()}); export const purchaseOrderStatusHistory = z.object({status: z.enum(["CANCELLED", "CLOSED", "CONFIRMED", "MANUALLY_CLOSED", "ORDER_DOCUMENTS_PRINTED", "ORDER_ENTRY_COMPLETED", "ORDER_ENTRY_IN_PROGRESS"]).optional(), statusDate: z.number().int().optional(), userId: z.string().optional()}); export const purchaseOrder = z.object({id: z.string().optional(), version: z.string().optional(), advancePaymentStatus: z.enum(["OPEN", "PAID"]).optional(), blanketSalesOrderId: z.string().optional(), commercialLanguage: z.string().optional(), commercialLanguageCustomer: z.string().optional(), commission: z.string().optional(), confirmationNumber: z.string().optional(), costCenterId: z.string().optional(), createdDate: z.number().int().optional(), creatorId: z.string().optional(), currencyConversionDate: z.number().int().optional(), currencyConversionLocked: z.boolean().optional(), currencyConversionRate: z.string().optional(), customAttributes: z.array(customAttribute).optional(), deliveryAddress: recordAddress.optional(), description: z.string().optional(), disableRecordEmailingRule: z.boolean().optional(), dropshippingDeliveryNoteFormTexts: dropshippingDeliveryNoteFormTextBlockData.optional(), externalPurchaseOrderNumber: z.string().optional(), formSettingsFromSalesChannel: z.string().optional(), grossAmount: z.string().optional(), grossAmountInCompanyCurrency: z.string().optional(), grossAmountWithoutShippingCosts: z.string().optional(), grossAmountWithoutShippingCostsInCompanyCurrency: z.string().optional(), headerDiscount: z.string().optional(), headerSurcharge: z.string().optional(), includeCashDiscountInValuationPrice: z.boolean().optional(), invoiceAddress: recordAddress.optional(), invoiced: z.boolean().optional(), lastModifiedDate: z.number().int().optional(), lastStatusChangeUserId: z.string().optional(), mergedToPurchaseOrderId: z.string().optional(), netAmount: z.string().optional(), netAmountInCompanyCurrency: z.string().optional(), netAmountWithoutShippingCosts: z.string().optional(), netAmountWithoutShippingCostsInCompanyCurrency: z.string().optional(), nonStandardTaxId: z.string().optional(), note: z.string().optional(), orderDate: z.number().int().optional(), packageTrackingNumber: z.string().optional(), packageTrackingUrl: z.string().optional(), paid: z.boolean().optional(), paymentMethodId: z.string().optional(), plannedDeliveryDate: z.number().int().optional(), plannedShippingDate: z.number().int().optional(), purchaseOrderItems: z.array(purchaseOrderItem).optional(), purchaseOrderNumber: z.string().optional(), purchaseOrderRequestId: z.string().optional(), purchaseOrderType: z.enum(["DROPSHIPPING", "NORMAL", "SALES_ORDER_COMMISSION"]).optional(), received: z.boolean().optional(), recipientCountryCode: z.enum(["AC", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CS", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DG", "DJ", "DK", "DM", "DO", "DZ", "EA", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "EU", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "IC", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TA", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "UNKNOWN", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "XI", "XK", "YE", "YT", "ZA", "ZM", "ZW"]).optional(), recordAddress: recordAddress.optional(), recordComment: z.string().optional(), recordCurrencyId: z.string(), recordEmailAddresses: emailAddresses.optional(), recordFreeText: z.string().optional(), recordOpening: z.string().optional(), responsibleUserId: z.string().optional(), salesOrderId: z.string().optional(), senderCountryCode: z.enum(["AC", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AN", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CS", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DG", "DJ", "DK", "DM", "DO", "DZ", "EA", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "EU", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "IC", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TA", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "UNKNOWN", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "XI", "XK", "YE", "YT", "ZA", "ZM", "ZW"]), sentToRecipient: z.boolean().optional(), servicePeriodFrom: z.number().int().optional(), servicePeriodTo: z.number().int().optional(), shipmentMethodId: z.string().optional(), shippingCarrierId: z.string().optional(), shippingCostItems: z.array(purchaseOrderShippingCostItem).optional(), shippingNotificationDate: z.number().int().optional(), status: z.enum(["CANCELLED", "CLOSED", "CONFIRMED", "MANUALLY_CLOSED", "ORDER_DOCUMENTS_PRINTED", "ORDER_ENTRY_COMPLETED", "ORDER_ENTRY_IN_PROGRESS"]), statusHistory: z.array(purchaseOrderStatusHistory).optional(), supplierHabitualExporterLetterOfIntentId: z.string().optional(), supplierId: z.string(), supplierQuotationNumber: z.string().optional(), tags: z.array(z.string()).optional(), termOfPaymentId: z.string().optional(), vatAmount: z.string().optional(), vatAmountInCompanyCurrency: z.string().optional(), warehouseId: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * create a purchaseOrder * * POST /purchaseOrder */ export const createApiPurchaseOrder = async (args: CreateApiPurchaseOrderArgs, options: CreateApiPurchaseOrderOptions) => { const {baseUrl, fetch: fetchFn = fetch, APIToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.dryRun != null) query.append("dryRun", String(args.dryRun)) if (APIToken !== undefined) headers.set("AuthenticationToken", APIToken) const url = `${baseUrl.replace(/\/+$/, '')}/purchaseOrder${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 validateResponse(purchaseOrder, await res.json()) };