import {z} from 'zod' export type HazmatInfo = {category: 'defined' | 'aerosols_flammable' | 'contains_lithium_ion' | 'packaged_lithium_ion' | 'lithium_ion_battery_only' | 'contains_lithium_metal' | 'packaged_lithium_metal' | 'lithium_metal_battery_only' | 'dry_ice', quantity: number, quantityType: 'gross' | 'net', quantityUnits: 'g' | 'kg' | 'lb' | 'oz' | 'ml' | 'l' | 'gal', containerType: 'fiberboard_box' | 'wooden_box' | 'plastic_jerrican' | 'metal_box' | 'steel_drum' | 'other' | 'plastic_box' | 'plastic_drum' | 'styrofoam_box' | 'cylinder' | 'envirotainer' | 'plywood_box' | 'aluminum_drum' | 'aluminum_cylinder' | 'plastic_pail' | 'plywood_drum' | 'fiber_drum' | 'steel_jerrican' | 'aluminum_jerrican' | 'steel_box' | 'carton' | 'aluminum_box', hazmatId?: string | undefined, properShippingName?: string | undefined, packingGroup?: ('I' | 'II' | 'III') | undefined, transportMode?: ('ground' | 'passenger_and_cargo_aircraft' | 'cargo_aircraft_only') | undefined, packingInstructionCode?: string | undefined, hazardClass?: ('class_1_explosive' | 'class_2_flammable_gas' | 'class_3_flammable_liquid' | 'class_4_flammable_solid' | 'class_5_organic_peroxide' | 'class_6_poisonous_material' | 'class_7_radioactive' | 'class_8_corrosive_material' | 'class_9_miscellaneous' | 'forbidden' | 'other') | undefined, subsidiaryClasses?: Array | undefined, numberOfInnerPackagings?: number | undefined, innerPackagingType?: string | undefined, outerPackagingType?: string | undefined, shipperDeclarationStatement?: ('FDG' | 'LQ_air' | 'EQ' | 'small_battery_air' | 'small_battery_ground' | 'cargo_aircraft_only') | undefined, wattHours?: number | undefined, lithiumContent?: number | undefined, numberOfCells?: number | undefined, numberOfBatteries?: number | undefined, batteryConfiguration?: ('contained_in_equipment' | 'packed_with_equipment' | 'standalone') | undefined}; export type Weight = {weightUnit?: ('g' | 'kg' | 'oz' | 'lb') | undefined, weight?: number | undefined}; export type OrderItem = {orderItemReferenceIdentifier?: string | undefined, shipiumOrderId?: string | undefined, partnerOrderId?: string | undefined, hazmat?: boolean | undefined, hazmatInfo?: HazmatInfo | undefined, productTaxCode?: string | undefined, nmfcCode?: string | undefined, nmfcFreightClass?: string | undefined, deliveryEstimateId?: string | undefined, productId: string, quantity: number, productDetails?: Array | undefined, itemWeight?: Weight | undefined, productDescription?: string | undefined, serialNumbers?: Array | undefined}; export type AddressLineComponents = {streetName?: string | undefined, primaryAddressNumber?: string | undefined, secondaryAddressNumber?: string | undefined, district?: string | undefined, neighborhood?: string | undefined}; export type CSAddress = {name?: string | undefined, phoneNumber?: string | undefined, phoneNumberCountryCode?: string | undefined, emailAddress?: string | undefined, company?: string | undefined, street1?: string | undefined, street2?: string | undefined, city?: string | undefined, state?: string | undefined, countryCode: string, postalCode: string, addressType?: ('commercial' | 'residential') | undefined, addressLineComponents?: AddressLineComponents | undefined}; export type InvoicePrePaidAmount = {value?: number | undefined, currencyCode?: string | undefined}; export type WindsorFrameworkInfo = {atRisk?: boolean | undefined}; export type EuropeanUnionInfo = {vendorIossNumber?: string | undefined, vendorIossAddress?: CSAddress | undefined, windsorFramework?: WindsorFrameworkInfo | undefined}; export type ExportReturnInfo = {originalExportDate?: string | undefined, originalExportTrackingId?: string | undefined, originalOutboundCarrier?: string | undefined}; export type ElectronicExportInformation = {exportDate?: string | undefined, pointOfOrigin?: string | undefined}; export type StandardizedProductId = {type?: ('GTIN' | 'EAN' | 'UPC' | 'ISBN' | 'unknown') | undefined, value?: string | undefined}; export type ScheduleBInformation = {scheduleBNumber: string, scheduleBQuantity: number, scheduleBUnitOfMeasurement: 'barrels' | 'carat' | 'content_kilogram' | 'square_centimeter' | 'content_ton' | 'curie' | 'clean_yield_kilogram' | 'dozen' | 'dozen_pieces' | 'dozen_pairs' | 'fiber_meter' | 'gross_container' | 'gram' | 'gross' | 'hundred' | 'kilogram' | 'cubic_kilometer' | 'kilogram_total_sugars' | 'liter' | 'meter' | 'square_meter' | 'cubic_meter' | 'millicurie' | 'number' | 'pieces' | 'proof_liter' | 'pack' | 'pairs' | 'running_bales' | 'square' | 'ton' | 'thousand' | 'no_quantity_required' | 'unknown'}; export type ExportLicense = {licenseNumber: string, licenseLineValue: number, licenseExpiration: string}; export type ExportLicenseInformation = {licenseType: string, licenseExemptionCode?: string | undefined, exportLicense?: ExportLicense | undefined}; export type ElectronicExportCommodityInformation = {exportType: 'domestic' | 'foreign' | 'unknown', exportInformationCode: string, scheduleBInformation: ScheduleBInformation, eccnNumber: string, exportLicenseInformation: ExportLicenseInformation}; export type CpscCertificateOfCompliance = {filingMode: 'FULL' | 'REFERENCE', cpscProductId?: string | undefined, applicableCpscRules?: Array | undefined, dateOfManufacture?: string | undefined, manufacturerName?: string | undefined, manufacturerAddress?: CSAddress | undefined, lastComplianceTestingDate?: string | undefined, testingLabName?: string | undefined, testingLabAddress?: CSAddress | undefined, testingLabContactInfo?: string | undefined, importerRecordKeeperContact?: string | undefined, registryProductId?: string | undefined, registryVersionId?: string | undefined, registryCertifierId?: string | undefined}; export type CustomsItemData = {customsValue?: number | undefined, customsValueCurrency?: string | undefined, commodityDescription?: string | undefined, countryOfManufacture?: string | undefined, customsWeight?: Weight | undefined, quantity?: number | undefined, productId?: string | undefined, standardizedProductIds?: Array | undefined, manufacturerProductId?: string | undefined, quantityUnitOfMeasurement?: ('bag' | 'barrel' | 'box' | 'case_of_goods' | 'container' | 'crate' | 'cylinder' | 'envelope' | 'pallet' | 'piece' | 'roll' | 'tube' | 'unknown') | undefined, harmonizedTariffNumber?: string | undefined, importHarmonizedTariffNumber?: string | undefined, commodityPartNumber?: string | undefined, marksAndNumbers?: string | undefined, electronicExportCommodityInformation?: ElectronicExportCommodityInformation | undefined, b13AFilingOption?: ('NOT_REQUIRED' | 'MANUALLY_ATTACHED' | 'FILED_ELECTRONICALLY' | 'SUMMARY_REPORTING' | 'CARRIER_TO_STAMP' | 'UNKNOWN') | undefined, exportComplianceStatement?: string | undefined, cpscCertificateOfCompliance?: CpscCertificateOfCompliance | undefined}; export type RequestTaxIdentificationNumber = {number?: string | undefined, tinType?: ('PERSONAL_NATIONAL' | 'PERSONAL_STATE' | 'FEDERAL' | 'BUSINESS_NATIONAL' | 'BUSINESS_STATE' | 'BUSINESS_UNION') | undefined}; export type ImporterOfRecord = {importerAddress?: CSAddress | undefined, accountNumber?: string | undefined, taxIdentificationNumbers?: Array | undefined}; export type Broker = {brokerAddress?: CSAddress | undefined, accountNumber?: string | undefined, taxIdentificationNumbers?: Array | undefined, deliveryInstructions?: string | undefined, type?: ('IMPORT' | 'EXPORT') | undefined}; export type SoldTo = {address?: CSAddress | undefined, accountNumber?: string | undefined, taxIdentificationNumbers?: Array | undefined}; export type RequestCustomsInfo = {totalCustomsValue?: number | undefined, totalCustomsValueCurrency?: string | undefined, customsDescription?: string | undefined, reasonForExport?: ('sale' | 'gift' | 'sample' | 'returns' | 'personal_effects' | 'unknown') | undefined, businessIndicator?: ('B2C' | 'B2B' | 'unknown') | undefined, invoiceDate?: string | undefined, invoiceNumber?: string | undefined, invoicePrePaidAmount?: InvoicePrePaidAmount | undefined, europeanUnionInfo?: EuropeanUnionInfo | undefined, exportReturnInfo?: ExportReturnInfo | undefined, ultimateConsigneeAddress?: CSAddress | undefined, ultimateConsigneeType?: ('direct_consumer' | 'government_entity' | 'reseller' | 'unknown') | undefined, aesInternalTransactionNumber?: string | undefined, electronicExportInformation?: ElectronicExportInformation | undefined, b13AFilingOption?: ('NOT_REQUIRED' | 'MANUALLY_ATTACHED' | 'FILED_ELECTRONICALLY' | 'SUMMARY_REPORTING' | 'CARRIER_TO_STAMP' | 'UNKNOWN') | undefined, exportComplianceStatement?: string | undefined, permitNumber?: string | undefined, customsItems?: Array | undefined, incoterm?: ('DDP' | 'DDU' | 'DAP' | 'DPU' | 'FCA' | 'CPT' | 'FOB' | 'EXW') | undefined, declarationStatement?: string | undefined, taxIdentificationNumber?: string | undefined, importerOfRecord?: ImporterOfRecord | undefined, brokers?: Array | undefined, soldTo?: SoldTo | undefined}; export type DeclaredValue = {declaredValue?: number | undefined, currencyCode?: string | undefined}; export type TimeWindow = {startWindow: string, endWindow: string, timeZone?: string | undefined}; export type DesiredDeliveryDateOptions = {exactDateDelivery?: boolean | undefined}; export type Tip = {type?: ('FIXED' | 'PERCENTAGE') | undefined, value?: number | undefined, currency?: string | undefined}; export type LastMileDeliveryOptions = {deliveryInstruction?: ('LEAVE_AT_DOOR' | 'MEET_AT_DOOR') | undefined, undeliverableInstruction?: ('LEAVE_AT_DOOR' | 'RETURN' | 'DESTROY') | undefined, tip?: Tip | undefined, tipForLabelCreate?: Tip | undefined, deliverableActionForLabelCreate?: ('RETURN' | 'LEAVE_AT_DOOR' | 'DISCARD' | 'MEET_AT_DOOR') | undefined, undeliverableActionForLabelCreate?: ('RETURN' | 'LEAVE_AT_DOOR' | 'DISCARD' | 'MEET_AT_DOOR') | undefined}; export type OrderDeliveryParameters = {applyToSplits?: boolean | undefined, businessDaysOfTransit?: number | undefined, deliveryNote?: string | undefined, deliverySignatureOption?: ('None' | 'Signature' | 'ResidentSignature' | 'AdultSignature' | 'AdultResidentSignature' | 'Unknown') | undefined, deliveryWindow?: TimeWindow | undefined, desiredDeliveryDate?: string | undefined, desiredDeliveryDateOptions?: DesiredDeliveryDateOptions | undefined, lastMileDeliveryOptions?: LastMileDeliveryOptions | undefined, preferredCarrierDeliveryDateTime?: string | undefined, saturdayDelivery?: boolean | undefined, carrierServiceMethodAllowList?: Array | undefined, intendedShipDateTime?: string | undefined}; export type HoldAtLocation = {holdAtLocationId?: string | undefined, useHoldAtLocation?: boolean | undefined}; export type OrderItemReference = {orderItemReferenceIdentifier?: string | undefined, productId: string, quantity: number}; export type LinearDimensions = {linearUnit?: ('in' | 'cm') | undefined, length?: number | undefined, width?: number | undefined, height?: number | undefined}; export type PackagingTypeParameters = {packagingMaterial?: ('box' | 'envelope' | 'flat_pack' | 'fedex_one_rate_envelope' | 'fedex_one_rate_pak' | 'fedex_one_rate_extra_small_box' | 'fedex_one_rate_small_box' | 'fedex_one_rate_medium_box' | 'fedex_one_rate_large_box' | 'fedex_one_rate_extra_large_box' | 'fedex_one_rate_tube' | 'fedex_ten_kg_box' | 'fedex_twenty_five_kg_box' | 'mailing_tube' | 'parcel_pallet' | 'small_tire' | 'large_tire' | 'usps_large_box' | 'usps_large_box_to_apo_fpo_dpo' | 'usps_medium_box' | 'usps_small_box' | 'usps_legal_envelope' | 'usps_envelope' | 'usps_padded_envelope' | 'ups_express_envelope') | undefined, packagingSizeName?: string | undefined, packagingTypeId?: string | undefined, linearDimensions?: LinearDimensions | undefined, packagingWeight?: Weight | undefined}; export type OrderSplitParameters = {splitReferenceId?: string | undefined, reasonCode?: ('customer_request' | 'item_size' | 'stock_not_available') | undefined, fulfilled?: boolean | undefined, saturdayDelivery?: boolean | undefined, thirdPartyBillingSetId?: string | undefined, forceThirdPartyBilling?: boolean | undefined, orderItemQuantities: Array, packagingType?: PackagingTypeParameters | undefined, totalWeight?: Weight | undefined}; export type OrderFulfillmentParameters = {deliveryParameters?: OrderDeliveryParameters | undefined, saturdayDelivery?: boolean | undefined, thirdPartyBillingSetId?: string | undefined, forceThirdPartyBilling?: boolean | undefined, fulfillmentContext?: string | undefined, fulfillmentContextId?: string | undefined, holdAtLocation?: HoldAtLocation | undefined, referenceIdentifier?: string | undefined, referenceIdentifier2?: string | undefined, referenceIdentifier3?: string | undefined, referenceIdentifier4?: string | undefined, referenceIdentifier5?: string | undefined, partnerReferenceIdentifier?: string | undefined, partnerReferenceIdentifier2?: string | undefined, splitOrder?: boolean | undefined, splitParameters?: Array | undefined, packagingType?: PackagingTypeParameters | undefined, totalWeight?: Weight | undefined, shipmentTags?: Array | undefined}; export type OrderCreate = {fulfillmentType?: ('customer' | 'at_large' | 'returns' | 'hundredweight' | 'reship' | 'unknown') | undefined, orderSource?: ('shipium' | 'external') | undefined, partnerOrderId?: string | undefined, associatedIdentifiers?: Array | undefined, tenantId?: string | undefined, orderedDateTime: string, orderItemQuantities: Array, shipFromAddress?: CSAddress | undefined, originId?: string | undefined, destinationAddress: CSAddress, returnToAddress?: CSAddress | undefined, shipOption?: string | undefined, customsInfo?: RequestCustomsInfo | undefined, currencyCode?: string | undefined, totalDeclaredValue?: DeclaredValue | undefined, orderFulfillmentParameters?: OrderFulfillmentParameters | undefined}; export type CreateApiApiV1PackShipOrderArgs = {body: OrderCreate}; export type CreateApiApiV1PackShipOrderOptions = {baseUrl?: string | undefined, oauth2Scheme?: string | undefined, fetch?: typeof fetch | undefined}; export const hazmatInfo = z.object({category: z.enum(["defined", "aerosols_flammable", "contains_lithium_ion", "packaged_lithium_ion", "lithium_ion_battery_only", "contains_lithium_metal", "packaged_lithium_metal", "lithium_metal_battery_only", "dry_ice"]), quantity: z.number(), quantityType: z.enum(["gross", "net"]), quantityUnits: z.enum(["g", "kg", "lb", "oz", "ml", "l", "gal"]), containerType: z.enum(["fiberboard_box", "wooden_box", "plastic_jerrican", "metal_box", "steel_drum", "other", "plastic_box", "plastic_drum", "styrofoam_box", "cylinder", "envirotainer", "plywood_box", "aluminum_drum", "aluminum_cylinder", "plastic_pail", "plywood_drum", "fiber_drum", "steel_jerrican", "aluminum_jerrican", "steel_box", "carton", "aluminum_box"]), hazmatId: z.string().optional(), properShippingName: z.string().optional(), packingGroup: z.enum(["I", "II", "III"]).optional(), transportMode: z.enum(["ground", "passenger_and_cargo_aircraft", "cargo_aircraft_only"]).optional(), packingInstructionCode: z.string().optional(), hazardClass: z.enum(["class_1_explosive", "class_2_flammable_gas", "class_3_flammable_liquid", "class_4_flammable_solid", "class_5_organic_peroxide", "class_6_poisonous_material", "class_7_radioactive", "class_8_corrosive_material", "class_9_miscellaneous", "forbidden", "other"]).optional(), subsidiaryClasses: z.array(z.string()).optional(), numberOfInnerPackagings: z.number().int().optional(), innerPackagingType: z.string().optional(), outerPackagingType: z.string().optional(), shipperDeclarationStatement: z.enum(["FDG", "LQ_air", "EQ", "small_battery_air", "small_battery_ground", "cargo_aircraft_only"]).optional(), wattHours: z.number().optional(), lithiumContent: z.number().optional(), numberOfCells: z.number().int().optional(), numberOfBatteries: z.number().int().optional(), batteryConfiguration: z.enum(["contained_in_equipment", "packed_with_equipment", "standalone"]).optional()}); export const weight = z.object({weightUnit: z.enum(["g", "kg", "oz", "lb"]).optional(), weight: z.number().optional()}); export const orderItem = z.object({orderItemReferenceIdentifier: z.string().optional(), shipiumOrderId: z.string().optional(), partnerOrderId: z.string().optional(), hazmat: z.boolean().optional(), hazmatInfo: hazmatInfo.optional(), productTaxCode: z.string().optional(), nmfcCode: z.string().optional(), nmfcFreightClass: z.string().optional(), deliveryEstimateId: z.string().optional(), productId: z.string(), quantity: z.number().int(), productDetails: z.array(z.string()).optional(), itemWeight: weight.optional(), productDescription: z.string().optional(), serialNumbers: z.array(z.string()).optional()}); export const addressLineComponents = z.object({streetName: z.string().optional(), primaryAddressNumber: z.string().optional(), secondaryAddressNumber: z.string().optional(), district: z.string().optional(), neighborhood: z.string().optional()}); export const cSAddress = z.object({name: z.string().optional(), phoneNumber: z.string().optional(), phoneNumberCountryCode: z.string().optional(), emailAddress: z.string().optional(), company: z.string().optional(), street1: z.string().optional(), street2: z.string().optional(), city: z.string().optional(), state: z.string().optional(), countryCode: z.string(), postalCode: z.string(), addressType: z.enum(["commercial", "residential"]).optional(), addressLineComponents: addressLineComponents.optional()}); export const invoicePrePaidAmount = z.object({value: z.number().optional(), currencyCode: z.string().optional()}); export const windsorFrameworkInfo = z.object({atRisk: z.boolean().optional()}); export const europeanUnionInfo = z.object({vendorIossNumber: z.string().optional(), vendorIossAddress: cSAddress.optional(), windsorFramework: windsorFrameworkInfo.optional()}); export const exportReturnInfo = z.object({originalExportDate: z.string().optional(), originalExportTrackingId: z.string().optional(), originalOutboundCarrier: z.string().optional()}); export const electronicExportInformation = z.object({exportDate: z.string().optional(), pointOfOrigin: z.string().optional()}); export const standardizedProductId = z.object({type: z.enum(["GTIN", "EAN", "UPC", "ISBN", "unknown"]).optional(), value: z.string().optional()}); export const scheduleBInformation = z.object({scheduleBNumber: z.string(), scheduleBQuantity: z.number().int(), scheduleBUnitOfMeasurement: z.enum(["barrels", "carat", "content_kilogram", "square_centimeter", "content_ton", "curie", "clean_yield_kilogram", "dozen", "dozen_pieces", "dozen_pairs", "fiber_meter", "gross_container", "gram", "gross", "hundred", "kilogram", "cubic_kilometer", "kilogram_total_sugars", "liter", "meter", "square_meter", "cubic_meter", "millicurie", "number", "pieces", "proof_liter", "pack", "pairs", "running_bales", "square", "ton", "thousand", "no_quantity_required", "unknown"])}); export const exportLicense = z.object({licenseNumber: z.string(), licenseLineValue: z.number().int(), licenseExpiration: z.string()}); export const exportLicenseInformation = z.object({licenseType: z.string(), licenseExemptionCode: z.string().optional(), exportLicense: exportLicense.optional()}); export const electronicExportCommodityInformation = z.object({exportType: z.enum(["domestic", "foreign", "unknown"]), exportInformationCode: z.string(), scheduleBInformation: scheduleBInformation, eccnNumber: z.string(), exportLicenseInformation: exportLicenseInformation}); export const cpscCertificateOfCompliance = z.object({filingMode: z.enum(["FULL", "REFERENCE"]), cpscProductId: z.string().optional(), applicableCpscRules: z.array(z.string()).optional(), dateOfManufacture: z.string().optional(), manufacturerName: z.string().optional(), manufacturerAddress: cSAddress.optional(), lastComplianceTestingDate: z.string().optional(), testingLabName: z.string().optional(), testingLabAddress: cSAddress.optional(), testingLabContactInfo: z.string().optional(), importerRecordKeeperContact: z.string().optional(), registryProductId: z.string().optional(), registryVersionId: z.string().optional(), registryCertifierId: z.string().optional()}); export const customsItemData = z.object({customsValue: z.number().optional(), customsValueCurrency: z.string().optional(), commodityDescription: z.string().min(3).optional(), countryOfManufacture: z.string().optional(), customsWeight: weight.optional(), quantity: z.number().int().optional(), productId: z.string().optional(), standardizedProductIds: z.array(standardizedProductId).optional(), manufacturerProductId: z.string().optional(), quantityUnitOfMeasurement: z.enum(["bag", "barrel", "box", "case_of_goods", "container", "crate", "cylinder", "envelope", "pallet", "piece", "roll", "tube", "unknown"]).optional(), harmonizedTariffNumber: z.string().optional(), importHarmonizedTariffNumber: z.string().optional(), commodityPartNumber: z.string().optional(), marksAndNumbers: z.string().optional(), electronicExportCommodityInformation: electronicExportCommodityInformation.optional(), b13AFilingOption: z.enum(["NOT_REQUIRED", "MANUALLY_ATTACHED", "FILED_ELECTRONICALLY", "SUMMARY_REPORTING", "CARRIER_TO_STAMP", "UNKNOWN"]).optional(), exportComplianceStatement: z.string().optional(), cpscCertificateOfCompliance: cpscCertificateOfCompliance.optional()}); export const requestTaxIdentificationNumber = z.object({number: z.string().optional(), tinType: z.enum(["PERSONAL_NATIONAL", "PERSONAL_STATE", "FEDERAL", "BUSINESS_NATIONAL", "BUSINESS_STATE", "BUSINESS_UNION"]).optional()}); export const importerOfRecord = z.object({importerAddress: cSAddress.optional(), accountNumber: z.string().optional(), taxIdentificationNumbers: z.array(requestTaxIdentificationNumber).optional()}); export const broker = z.object({brokerAddress: cSAddress.optional(), accountNumber: z.string().optional(), taxIdentificationNumbers: z.array(requestTaxIdentificationNumber).optional(), deliveryInstructions: z.string().optional(), type: z.enum(["IMPORT", "EXPORT"]).optional()}); export const soldTo = z.object({address: cSAddress.optional(), accountNumber: z.string().optional(), taxIdentificationNumbers: z.array(requestTaxIdentificationNumber).optional()}); export const requestCustomsInfo = z.object({totalCustomsValue: z.number().optional(), totalCustomsValueCurrency: z.string().optional(), customsDescription: z.string().optional(), reasonForExport: z.enum(["sale", "gift", "sample", "returns", "personal_effects", "unknown"]).optional(), businessIndicator: z.enum(["B2C", "B2B", "unknown"]).optional(), invoiceDate: z.string().optional(), invoiceNumber: z.string().optional(), invoicePrePaidAmount: invoicePrePaidAmount.optional(), europeanUnionInfo: europeanUnionInfo.optional(), exportReturnInfo: exportReturnInfo.optional(), ultimateConsigneeAddress: cSAddress.optional(), ultimateConsigneeType: z.enum(["direct_consumer", "government_entity", "reseller", "unknown"]).optional(), aesInternalTransactionNumber: z.string().optional(), electronicExportInformation: electronicExportInformation.optional(), b13AFilingOption: z.enum(["NOT_REQUIRED", "MANUALLY_ATTACHED", "FILED_ELECTRONICALLY", "SUMMARY_REPORTING", "CARRIER_TO_STAMP", "UNKNOWN"]).optional(), exportComplianceStatement: z.string().optional(), permitNumber: z.string().optional(), customsItems: z.array(customsItemData).optional(), incoterm: z.enum(["DDP", "DDU", "DAP", "DPU", "FCA", "CPT", "FOB", "EXW"]).optional(), declarationStatement: z.string().optional(), taxIdentificationNumber: z.string().optional(), importerOfRecord: importerOfRecord.optional(), brokers: z.array(broker).optional(), soldTo: soldTo.optional()}); export const declaredValue = z.object({declaredValue: z.number().optional(), currencyCode: z.string().optional()}); export const timeWindow = z.object({startWindow: z.string(), endWindow: z.string(), timeZone: z.string().optional()}); export const desiredDeliveryDateOptions = z.object({exactDateDelivery: z.boolean().optional()}); export const tip = z.object({type: z.enum(["FIXED", "PERCENTAGE"]).optional(), value: z.number().optional(), currency: z.string().optional()}); export const lastMileDeliveryOptions = z.object({deliveryInstruction: z.enum(["LEAVE_AT_DOOR", "MEET_AT_DOOR"]).optional(), undeliverableInstruction: z.enum(["LEAVE_AT_DOOR", "RETURN", "DESTROY"]).optional(), tip: tip.optional(), tipForLabelCreate: tip.optional(), deliverableActionForLabelCreate: z.enum(["RETURN", "LEAVE_AT_DOOR", "DISCARD", "MEET_AT_DOOR"]).optional(), undeliverableActionForLabelCreate: z.enum(["RETURN", "LEAVE_AT_DOOR", "DISCARD", "MEET_AT_DOOR"]).optional()}); export const orderDeliveryParameters = z.object({applyToSplits: z.boolean().optional(), businessDaysOfTransit: z.number().int().optional(), deliveryNote: z.string().optional(), deliverySignatureOption: z.enum(["None", "Signature", "ResidentSignature", "AdultSignature", "AdultResidentSignature", "Unknown"]).optional(), deliveryWindow: timeWindow.optional(), desiredDeliveryDate: z.string().optional(), desiredDeliveryDateOptions: desiredDeliveryDateOptions.optional(), lastMileDeliveryOptions: lastMileDeliveryOptions.optional(), preferredCarrierDeliveryDateTime: z.string().optional(), saturdayDelivery: z.boolean().optional(), carrierServiceMethodAllowList: z.array(z.string()).optional(), intendedShipDateTime: z.string().optional()}); export const holdAtLocation = z.object({holdAtLocationId: z.string().optional(), useHoldAtLocation: z.boolean().optional()}); export const orderItemReference = z.object({orderItemReferenceIdentifier: z.string().optional(), productId: z.string(), quantity: z.number().int()}); export const linearDimensions = z.object({linearUnit: z.enum(["in", "cm"]).optional(), length: z.number().optional(), width: z.number().optional(), height: z.number().optional()}); export const packagingTypeParameters = z.object({packagingMaterial: z.enum(["box", "envelope", "flat_pack", "fedex_one_rate_envelope", "fedex_one_rate_pak", "fedex_one_rate_extra_small_box", "fedex_one_rate_small_box", "fedex_one_rate_medium_box", "fedex_one_rate_large_box", "fedex_one_rate_extra_large_box", "fedex_one_rate_tube", "fedex_ten_kg_box", "fedex_twenty_five_kg_box", "mailing_tube", "parcel_pallet", "small_tire", "large_tire", "usps_large_box", "usps_large_box_to_apo_fpo_dpo", "usps_medium_box", "usps_small_box", "usps_legal_envelope", "usps_envelope", "usps_padded_envelope", "ups_express_envelope"]).optional(), packagingSizeName: z.string().optional(), packagingTypeId: z.string().optional(), linearDimensions: linearDimensions.optional(), packagingWeight: weight.optional()}); export const orderSplitParameters = z.object({splitReferenceId: z.string().optional(), reasonCode: z.enum(["customer_request", "item_size", "stock_not_available"]).optional(), fulfilled: z.boolean().optional(), saturdayDelivery: z.boolean().optional(), thirdPartyBillingSetId: z.string().optional(), forceThirdPartyBilling: z.boolean().optional(), orderItemQuantities: z.array(orderItemReference), packagingType: packagingTypeParameters.optional(), totalWeight: weight.optional()}); export const orderFulfillmentParameters = z.object({deliveryParameters: orderDeliveryParameters.optional(), saturdayDelivery: z.boolean().optional(), thirdPartyBillingSetId: z.string().optional(), forceThirdPartyBilling: z.boolean().optional(), fulfillmentContext: z.string().optional(), fulfillmentContextId: z.string().optional(), holdAtLocation: holdAtLocation.optional(), referenceIdentifier: z.string().optional(), referenceIdentifier2: z.string().optional(), referenceIdentifier3: z.string().optional(), referenceIdentifier4: z.string().optional(), referenceIdentifier5: z.string().optional(), partnerReferenceIdentifier: z.string().optional(), partnerReferenceIdentifier2: z.string().optional(), splitOrder: z.boolean().optional(), splitParameters: z.array(orderSplitParameters).optional(), packagingType: packagingTypeParameters.optional(), totalWeight: weight.optional(), shipmentTags: z.array(z.string()).optional()}); export const orderShipmentInfo = z.object({shipiumShipmentId: z.string().optional(), partnerShipmentId: z.string().optional(), shipiumOrderId: z.string().optional(), partnerOrderId: z.string().optional(), parametersReferenceId: z.string().optional(), type: z.enum(["complete", "consolidation", "split"]).optional(), carrierTrackingId: z.string().optional(), carrier: z.string().optional(), carrierServiceMethodId: z.string().optional(), orderItemQuantities: z.array(orderItemReference).optional()}); export const orderFulfillmentInfo = z.object({shipments: z.array(orderShipmentInfo).optional(), unfulfilledItems: z.array(orderItemReference).optional()}); export const order = z.object({fulfillmentType: z.enum(["customer", "at_large", "returns", "hundredweight", "reship", "unknown"]).optional(), orderSource: z.enum(["shipium", "external"]).optional(), tenantId: z.string().optional(), shipiumOrderId: z.string(), partnerOrderId: z.string().optional(), orderedDateTime: z.string(), orderItemQuantities: z.array(orderItem), associatedIdentifiers: z.array(z.string()).optional(), shipOption: z.string().optional(), originId: z.string().optional(), shipFromAddress: cSAddress.optional(), destinationAddress: cSAddress, returnToAddress: cSAddress.optional(), customsInfo: requestCustomsInfo.optional(), currencyCode: z.string().optional(), totalDeclaredValue: declaredValue.optional(), orderFulfillmentParameters: orderFulfillmentParameters.optional(), orderStatus: z.enum(["open", "open_split", "complete", "complete_multiship", "cancelled", "partial_ship", "error"]).optional(), orderFulfillmentInfo: orderFulfillmentInfo.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 }; /** * Creates an order to be packed. * * POST /api/v1/packShip/order */ export const createApiApiV1PackShipOrder = async (args: CreateApiApiV1PackShipOrderArgs, options?: CreateApiApiV1PackShipOrderOptions) => { const {baseUrl = "https://api.shipium.com", fetch: fetchFn = fetch, oauth2Scheme} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (oauth2Scheme !== undefined) headers.set('authorization', `Bearer ${oauth2Scheme}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/packShip/order${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(order, await res.json()) };