import {z} from 'zod' 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 ContractAdditionalAddress = {id?: string | undefined, version?: string | undefined, address?: RecordAddress | undefined, createdDate?: number | undefined, description?: string | undefined, lastModifiedDate?: number | undefined}; export type CommissionSalesPartner = {id?: string | undefined, version?: string | undefined, commissionFix?: unknown | undefined, commissionPercentage?: unknown | undefined, commissionType: 'FIX' | 'FIX_AND_MARGIN' | 'FIX_AND_REVENUE' | 'MARGIN' | 'NO_COMMISSION' | 'REVENUE', createdDate?: number | undefined, lastModifiedDate?: number | undefined, salesPartnerSupplierId: string}; export type ContractCostItem = {id?: string | undefined, version?: string | undefined, articleId?: string | undefined, createdDate?: number | undefined, description?: string | undefined, descriptionFixed?: boolean | undefined, discountPercentage?: unknown | undefined, interval: 'DAILY' | 'FIVE_YEARLY' | 'FOUR_YEARLY' | 'HALF_YEARLY' | 'MONTHLY' | 'NONE' | 'QUARTER' | 'THREE_YEARLY' | 'TWO_YEARLY' | 'WEEKLY' | 'YEARLY', intervalType: 'NON_RECURRENT' | 'RECURRENT', lastModifiedDate?: number | undefined, manualUnitPrice?: boolean | undefined, netAmount?: unknown | undefined, netAmountInCompanyCurrency?: unknown | undefined, note?: string | undefined, quantity?: unknown | undefined, servicePeriodFrom?: number | undefined, servicePeriodTo?: number | undefined, title?: string | undefined, unitId?: string | undefined, unitPrice?: unknown | undefined, unitPriceInCompanyCurrency?: unknown | undefined}; export type CostCenterWithDistributionPercentage = {id?: string | undefined, version?: string | undefined, costCenterId: string, createdDate?: number | undefined, distributionPercentage: unknown, lastModifiedDate?: number | undefined}; 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 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 ContractItem = {id?: string | undefined, version?: string | undefined, addPageBreakBefore?: boolean | undefined, articleId?: string | undefined, billingGroupId?: string | undefined, commissionSalesPartners?: Array | undefined, costCenterItems?: Array | undefined, costTypeId?: string | 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, interval: 'DAILY' | 'FIVE_YEARLY' | 'FOUR_YEARLY' | 'HALF_YEARLY' | 'MONTHLY' | 'NONE' | 'QUARTER' | 'THREE_YEARLY' | 'TWO_YEARLY' | 'WEEKLY' | 'YEARLY', intervalType: 'NON_RECURRENT' | 'RECURRENT', 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, nextContractBillingDate?: number | undefined, note?: string | undefined, parentItemId?: string | undefined, positionNumber?: number | undefined, previousContractBillingDate?: number | undefined, quantity?: unknown | undefined, reductionAdditionItems?: Array | undefined, servicePeriodFromDate?: number | undefined, servicePeriodToDate?: number | undefined, taxId?: string | undefined, title?: string | undefined, type: 'COST' | 'REVENUE', unitId?: string | undefined, unitPrice?: unknown | undefined, unitPriceInCompanyCurrency?: unknown | undefined}; export type EmailAddresses = {bccAddresses?: string | undefined, ccAddresses?: string | undefined, toAddresses?: string | undefined}; export type Contract = {id?: string | undefined, version?: string | undefined, additionalAddresses?: Array | undefined, authorizationUnitId?: string | undefined, automaticExtension?: boolean | undefined, billUntil?: ('CURRENT_MONTH_1' | 'CURRENT_MONTH_10' | 'CURRENT_MONTH_11' | 'CURRENT_MONTH_12' | 'CURRENT_MONTH_13' | 'CURRENT_MONTH_14' | 'CURRENT_MONTH_15' | 'CURRENT_MONTH_16' | 'CURRENT_MONTH_17' | 'CURRENT_MONTH_18' | 'CURRENT_MONTH_19' | 'CURRENT_MONTH_2' | 'CURRENT_MONTH_20' | 'CURRENT_MONTH_21' | 'CURRENT_MONTH_22' | 'CURRENT_MONTH_23' | 'CURRENT_MONTH_24' | 'CURRENT_MONTH_25' | 'CURRENT_MONTH_26' | 'CURRENT_MONTH_27' | 'CURRENT_MONTH_28' | 'CURRENT_MONTH_29' | 'CURRENT_MONTH_3' | 'CURRENT_MONTH_30' | 'CURRENT_MONTH_31' | 'CURRENT_MONTH_4' | 'CURRENT_MONTH_5' | 'CURRENT_MONTH_6' | 'CURRENT_MONTH_7' | 'CURRENT_MONTH_8' | 'CURRENT_MONTH_9' | 'NEXT_MONTH_1' | 'NEXT_MONTH_10' | 'NEXT_MONTH_11' | 'NEXT_MONTH_12' | 'NEXT_MONTH_13' | 'NEXT_MONTH_14' | 'NEXT_MONTH_15' | 'NEXT_MONTH_16' | 'NEXT_MONTH_17' | 'NEXT_MONTH_18' | 'NEXT_MONTH_19' | 'NEXT_MONTH_2' | 'NEXT_MONTH_20' | 'NEXT_MONTH_21' | 'NEXT_MONTH_22' | 'NEXT_MONTH_23' | 'NEXT_MONTH_24' | 'NEXT_MONTH_25' | 'NEXT_MONTH_26' | 'NEXT_MONTH_27' | 'NEXT_MONTH_28' | 'NEXT_MONTH_29' | 'NEXT_MONTH_3' | 'NEXT_MONTH_30' | 'NEXT_MONTH_31' | 'NEXT_MONTH_4' | 'NEXT_MONTH_5' | 'NEXT_MONTH_6' | 'NEXT_MONTH_7' | 'NEXT_MONTH_8' | 'NEXT_MONTH_9') | undefined, billingDay?: number | undefined, billingTargetInvoiceStatus?: ('DOCUMENT_CREATED' | 'NEW' | 'OPEN_ITEM_CREATED') | undefined, billingType?: ('INVOICE_AFTER' | 'INVOICE_BEFORE' | 'NONE' | 'NOT_INVOICEABLE' | 'SALES_ORDER') | undefined, cancellationDate?: number | undefined, cancellationPeriodQuantity?: number | undefined, cancellationPeriodSoftframe?: ('CONTRACT_END' | 'END_OF_CALENDAR_YEAR' | 'END_OF_CONTRACT_YEAR' | 'END_OF_MONTH' | 'END_OF_QUARTER' | 'FIFTEENTH_OF_MONTH' | 'FIFTEENTH_OR_END_OF_MONTH' | 'HALF_OF_CALENDAR_YEAR') | undefined, cancellationPeriodUnit?: ('DAY' | 'MONTH' | 'WEEK' | 'YEAR') | undefined, commercialLanguage?: string | undefined, commission?: string | undefined, commissionSalesPartners?: Array | undefined, contractCostItems?: Array | undefined, contractDate?: number | undefined, contractItems?: Array | undefined, contractNumber?: string | undefined, contractNumberAtParty?: string | undefined, contractStatus?: ('ACTIVE' | 'DRAFT' | 'INACTIVE') | undefined, correspondenceAddress?: RecordAddress | undefined, createdDate?: number | undefined, creatorId?: string | undefined, customAttributes?: Array | undefined, deliveryAddress?: RecordAddress | undefined, deliveryEmailAddresses?: EmailAddresses | undefined, depositLocationId?: string | undefined, description?: string | undefined, desiredSalesOrderStatus?: ('CANCELLED' | 'CLOSED' | 'MANUALLY_CLOSED' | 'ORDER_CONFIRMATION_PRINTED' | 'ORDER_ENTRY_IN_PROGRESS') | undefined, differingCorrespondenceAddress?: boolean | undefined, differingDeliveryAddress?: boolean | undefined, differingInvoiceAddress?: boolean | undefined, disableRecordEmailingRule?: boolean | undefined, endDate?: number | undefined, extensionQuantity?: number | undefined, extensionUnit?: ('DAY' | 'MONTH' | 'WEEK' | 'YEAR') | undefined, factoring?: boolean | undefined, formVariantId?: string | undefined, invoiceAddress?: RecordAddress | undefined, invoiceRecipientId?: string | undefined, lastModifiedDate?: number | undefined, latestCancellationWarningQuantity?: number | undefined, latestCancellationWarningUnit?: ('DAY' | 'MONTH' | 'WEEK' | 'YEAR') | undefined, latestPossibleTerminationDate?: number | undefined, name: string, nextContractBillingDate?: number | undefined, nonStandardInputTaxId?: string | undefined, nonStandardTaxId?: string | undefined, orderNumberAtCustomer?: string | undefined, organizationId?: string | undefined, partyId?: string | undefined, paymentMethodId?: string | undefined, pricingDate?: number | undefined, purchaseEmailAddresses?: EmailAddresses | undefined, recordComment?: string | undefined, recordCurrencyId: string, recordEmailAddresses?: EmailAddresses | undefined, recordFreeText?: string | undefined, recordOpening?: string | undefined, reminderDate?: number | undefined, reminderSendType?: ('MAIL' | 'NOTIFICATION') | undefined, reminderType?: ('AUTOMATIC_REMINDER' | 'DATE_REMINDER' | 'NO_REMINDER') | undefined, responsibleUserId?: string | undefined, salesChannel?: string | undefined, salesInvoiceEmailAddresses?: EmailAddresses | undefined, salesOrderEmailAddresses?: EmailAddresses | undefined, sentToRecipient?: boolean | undefined, sepaDirectDebitMandateId?: string | undefined, startDate?: number | undefined, tags?: Array | undefined, technicalContactPersonId?: string | undefined, template?: boolean | undefined, termOfPaymentId?: string | undefined, terminationReasonId?: string | undefined, ticketServiceLevelAgreementId?: string | undefined, types?: Array | undefined, unlimited?: boolean | undefined}; export type CreateApiContractArgs = {dryRun?: boolean | undefined, body: Contract}; export type CreateApiContractOptions = {baseUrl: string, APIToken?: string | undefined, fetch?: typeof fetch | undefined}; 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 contractAdditionalAddress = z.object({id: z.string().optional(), version: z.string().optional(), address: recordAddress.optional(), createdDate: z.number().int().optional(), description: z.string().optional(), lastModifiedDate: z.number().int().optional()}); export const commissionSalesPartner = z.object({id: z.string().optional(), version: z.string().optional(), commissionFix: z.string().optional(), commissionPercentage: z.string().optional(), commissionType: z.enum(["FIX", "FIX_AND_MARGIN", "FIX_AND_REVENUE", "MARGIN", "NO_COMMISSION", "REVENUE"]), createdDate: z.number().int().optional(), lastModifiedDate: z.number().int().optional(), salesPartnerSupplierId: z.string()}); export const contractCostItem = z.object({id: z.string().optional(), version: z.string().optional(), articleId: z.string().optional(), createdDate: z.number().int().optional(), description: z.string().optional(), descriptionFixed: z.boolean().optional(), discountPercentage: z.string().optional(), interval: z.enum(["DAILY", "FIVE_YEARLY", "FOUR_YEARLY", "HALF_YEARLY", "MONTHLY", "NONE", "QUARTER", "THREE_YEARLY", "TWO_YEARLY", "WEEKLY", "YEARLY"]), intervalType: z.enum(["NON_RECURRENT", "RECURRENT"]), lastModifiedDate: z.number().int().optional(), manualUnitPrice: z.boolean().optional(), netAmount: z.string().optional(), netAmountInCompanyCurrency: z.string().optional(), note: z.string().optional(), quantity: z.string().optional(), servicePeriodFrom: z.number().int().optional(), servicePeriodTo: z.number().int().optional(), title: z.string().optional(), unitId: z.string().optional(), unitPrice: z.string().optional(), unitPriceInCompanyCurrency: 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 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 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 contractItem = z.object({id: z.string().optional(), version: z.string().optional(), addPageBreakBefore: z.boolean().optional(), articleId: z.string().optional(), billingGroupId: z.string().optional(), commissionSalesPartners: z.array(commissionSalesPartner).optional(), costCenterItems: z.array(costCenterWithDistributionPercentage).optional(), costTypeId: z.string().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(), interval: z.enum(["DAILY", "FIVE_YEARLY", "FOUR_YEARLY", "HALF_YEARLY", "MONTHLY", "NONE", "QUARTER", "THREE_YEARLY", "TWO_YEARLY", "WEEKLY", "YEARLY"]), intervalType: z.enum(["NON_RECURRENT", "RECURRENT"]), 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(), nextContractBillingDate: z.number().int().optional(), note: z.string().optional(), parentItemId: z.string().optional(), positionNumber: z.number().int().optional(), previousContractBillingDate: z.number().int().optional(), quantity: z.string().optional(), reductionAdditionItems: z.array(reductionAdditionItem).optional(), servicePeriodFromDate: z.number().int().optional(), servicePeriodToDate: z.number().int().optional(), taxId: z.string().optional(), title: z.string().optional(), type: z.enum(["COST", "REVENUE"]), 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 contract = z.object({id: z.string().optional(), version: z.string().optional(), additionalAddresses: z.array(contractAdditionalAddress).optional(), authorizationUnitId: z.string().optional(), automaticExtension: z.boolean().optional(), billUntil: z.enum(["CURRENT_MONTH_1", "CURRENT_MONTH_10", "CURRENT_MONTH_11", "CURRENT_MONTH_12", "CURRENT_MONTH_13", "CURRENT_MONTH_14", "CURRENT_MONTH_15", "CURRENT_MONTH_16", "CURRENT_MONTH_17", "CURRENT_MONTH_18", "CURRENT_MONTH_19", "CURRENT_MONTH_2", "CURRENT_MONTH_20", "CURRENT_MONTH_21", "CURRENT_MONTH_22", "CURRENT_MONTH_23", "CURRENT_MONTH_24", "CURRENT_MONTH_25", "CURRENT_MONTH_26", "CURRENT_MONTH_27", "CURRENT_MONTH_28", "CURRENT_MONTH_29", "CURRENT_MONTH_3", "CURRENT_MONTH_30", "CURRENT_MONTH_31", "CURRENT_MONTH_4", "CURRENT_MONTH_5", "CURRENT_MONTH_6", "CURRENT_MONTH_7", "CURRENT_MONTH_8", "CURRENT_MONTH_9", "NEXT_MONTH_1", "NEXT_MONTH_10", "NEXT_MONTH_11", "NEXT_MONTH_12", "NEXT_MONTH_13", "NEXT_MONTH_14", "NEXT_MONTH_15", "NEXT_MONTH_16", "NEXT_MONTH_17", "NEXT_MONTH_18", "NEXT_MONTH_19", "NEXT_MONTH_2", "NEXT_MONTH_20", "NEXT_MONTH_21", "NEXT_MONTH_22", "NEXT_MONTH_23", "NEXT_MONTH_24", "NEXT_MONTH_25", "NEXT_MONTH_26", "NEXT_MONTH_27", "NEXT_MONTH_28", "NEXT_MONTH_29", "NEXT_MONTH_3", "NEXT_MONTH_30", "NEXT_MONTH_31", "NEXT_MONTH_4", "NEXT_MONTH_5", "NEXT_MONTH_6", "NEXT_MONTH_7", "NEXT_MONTH_8", "NEXT_MONTH_9"]).optional(), billingDay: z.number().int().optional(), billingTargetInvoiceStatus: z.enum(["DOCUMENT_CREATED", "NEW", "OPEN_ITEM_CREATED"]).optional(), billingType: z.enum(["INVOICE_AFTER", "INVOICE_BEFORE", "NONE", "NOT_INVOICEABLE", "SALES_ORDER"]).optional(), cancellationDate: z.number().int().optional(), cancellationPeriodQuantity: z.number().int().optional(), cancellationPeriodSoftframe: z.enum(["CONTRACT_END", "END_OF_CALENDAR_YEAR", "END_OF_CONTRACT_YEAR", "END_OF_MONTH", "END_OF_QUARTER", "FIFTEENTH_OF_MONTH", "FIFTEENTH_OR_END_OF_MONTH", "HALF_OF_CALENDAR_YEAR"]).optional(), cancellationPeriodUnit: z.enum(["DAY", "MONTH", "WEEK", "YEAR"]).optional(), commercialLanguage: z.string().optional(), commission: z.string().optional(), commissionSalesPartners: z.array(commissionSalesPartner).optional(), contractCostItems: z.array(contractCostItem).optional(), contractDate: z.number().int().optional(), contractItems: z.array(contractItem).optional(), contractNumber: z.string().optional(), contractNumberAtParty: z.string().optional(), contractStatus: z.enum(["ACTIVE", "DRAFT", "INACTIVE"]).optional(), correspondenceAddress: recordAddress.optional(), createdDate: z.number().int().optional(), creatorId: z.string().optional(), customAttributes: z.array(customAttribute).optional(), deliveryAddress: recordAddress.optional(), deliveryEmailAddresses: emailAddresses.optional(), depositLocationId: z.string().optional(), description: z.string().optional(), desiredSalesOrderStatus: z.enum(["CANCELLED", "CLOSED", "MANUALLY_CLOSED", "ORDER_CONFIRMATION_PRINTED", "ORDER_ENTRY_IN_PROGRESS"]).optional(), differingCorrespondenceAddress: z.boolean().optional(), differingDeliveryAddress: z.boolean().optional(), differingInvoiceAddress: z.boolean().optional(), disableRecordEmailingRule: z.boolean().optional(), endDate: z.number().int().optional(), extensionQuantity: z.number().int().optional(), extensionUnit: z.enum(["DAY", "MONTH", "WEEK", "YEAR"]).optional(), factoring: z.boolean().optional(), formVariantId: z.string().optional(), invoiceAddress: recordAddress.optional(), invoiceRecipientId: z.string().optional(), lastModifiedDate: z.number().int().optional(), latestCancellationWarningQuantity: z.number().int().optional(), latestCancellationWarningUnit: z.enum(["DAY", "MONTH", "WEEK", "YEAR"]).optional(), latestPossibleTerminationDate: z.number().int().optional(), name: z.string(), nextContractBillingDate: z.number().int().optional(), nonStandardInputTaxId: z.string().optional(), nonStandardTaxId: z.string().optional(), orderNumberAtCustomer: z.string().optional(), organizationId: z.string().optional(), partyId: z.string().optional(), paymentMethodId: z.string().optional(), pricingDate: z.number().int().optional(), purchaseEmailAddresses: emailAddresses.optional(), recordComment: z.string().optional(), recordCurrencyId: z.string(), recordEmailAddresses: emailAddresses.optional(), recordFreeText: z.string().optional(), recordOpening: z.string().optional(), reminderDate: z.number().int().optional(), reminderSendType: z.enum(["MAIL", "NOTIFICATION"]).optional(), reminderType: z.enum(["AUTOMATIC_REMINDER", "DATE_REMINDER", "NO_REMINDER"]).optional(), responsibleUserId: z.string().optional(), salesChannel: z.string().optional(), salesInvoiceEmailAddresses: emailAddresses.optional(), salesOrderEmailAddresses: emailAddresses.optional(), sentToRecipient: z.boolean().optional(), sepaDirectDebitMandateId: z.string().optional(), startDate: z.number().int().optional(), tags: z.array(z.string()).optional(), technicalContactPersonId: z.string().optional(), template: z.boolean().optional(), termOfPaymentId: z.string().optional(), terminationReasonId: z.string().optional(), ticketServiceLevelAgreementId: z.string().optional(), types: z.array(onlyId).optional(), unlimited: z.boolean().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 contract * * POST /contract */ export const createApiContract = async (args: CreateApiContractArgs, options: CreateApiContractOptions) => { 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(/\/+$/, '')}/contract${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(contract, await res.json()) };