import {z} from 'zod' export type DesiredDeliveryDateOptions = {exactDateDelivery?: boolean | 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 LtlBillToContact = {addressLineComponents?: AddressLineComponents | undefined, addressType?: ('commercial' | 'residential') | undefined, city?: string | undefined, company?: string | undefined, countryCode: string, emailAddress?: string | undefined, name?: string | undefined, phoneNumber?: string | undefined, phoneNumberCountryCode?: string | undefined, postalCode: string, state?: string | undefined, street1?: string | undefined, street2?: string | undefined, thirdPartyBillingSetId: string}; export type CurrencyAmount = {amount: number, currency?: string | undefined}; export type LtlHazmatContact = {contactName: string, phoneNumber: string, phoneNumberCountryCode?: string | undefined, email?: string | undefined}; export type LoadPackagingSizeRequest = {height: number, length: number, linearUnit?: ('in' | 'cm') | undefined, maximumWeight?: number | undefined, packagingWeight?: number | undefined, weightUnit?: ('g' | 'kg' | 'oz' | 'lb') | undefined, width: number}; export type LoadPackagingDetailsRequest = {loadPackagingType?: ('loose' | 'overboxed' | 'piece' | 'wrapped' | 'pallet') | undefined, loadPackagingSize: LoadPackagingSizeRequest}; export type LtlPaymentDetails = {payerType: 'consignee' | 'shipper' | 'thirdParty', paymentTerms: 'collect' | 'prePaid' | 'thirdParty'}; export type LtlShipmentParameters = {billToContact?: LtlBillToContact | undefined, carrierServiceMethodAllowList?: Array | undefined, collectOnDelivery?: CurrencyAmount | undefined, fulfillmentContextIds?: Array | undefined, originId?: string | undefined, fulfillmentType?: ('customer' | 'at_large' | 'returns' | 'hundredweight' | 'reship' | 'unknown') | undefined, hazmatContact?: LtlHazmatContact | undefined, packagingOptions?: Array | undefined, paymentDetails: LtlPaymentDetails, pickupDate: string, pricingTypes?: (Array<'all' | 'contract' | 'contractPallet' | 'dynamic' | 'volume' | 'unknown'>) | undefined, serviceLevels?: (Array<'all' | 'guaranteedMorning' | 'guaranteedNoon' | 'guaranteedEndOfDay' | 'standard' | 'unknown'>) | undefined, accessorialCodes?: (Array<'AIRD' | 'AIRP' | 'APTD' | 'APTP' | 'CFSD' | 'CFSP' | 'COD' | 'FSC' | 'GTD' | 'HAZ' | 'HCDA' | 'HCPA' | 'INS' | 'LTDAD' | 'LTDAP' | 'MISC' | 'MNC' | 'OVR' | 'PPD' | 'PSN' | 'REP' | 'RES' | 'SLTDAD' | 'SLTDAP' | 'SS' | 'WGDL' | 'WGDU'>) | undefined}; export type LoadPackagingSize = {height: number, length: number, linearUnit?: ('in' | 'cm') | undefined, weight: number, weightUnit?: ('g' | 'kg' | 'oz' | 'lb') | undefined, width: number}; export type LoadPackagingDetails = {declaredValue?: CurrencyAmount | undefined, loadPackagingType?: ('loose' | 'overboxed' | 'piece' | 'wrapped' | 'pallet') | undefined, loadPackagingSize: LoadPackagingSize, nmfcFreightClass: string}; 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 Weight = {weightUnit?: ('g' | 'kg' | 'oz' | 'lb') | undefined, weight?: number | 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 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 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 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 DeclaredValue = {declaredValue?: number | undefined, currencyCode?: string | undefined}; export type MultiParcelShipmentPackageParameters = {packageReferenceIdentifier: string, partnerProvidedPackageId?: string | undefined, orderItemQuantities: Array, packagingType?: PackagingTypeParameters | undefined, totalWeight?: Weight | undefined, totalDeclaredValue?: DeclaredValue | undefined, deliveredDateTime?: string | undefined}; export type LtlShipmentItem = {carrierProcessingId?: string | undefined, deliveryNote?: string | undefined, partnerReferenceIdentifier?: string | undefined, partnerReferenceIdentifier2?: string | undefined, purchaseOrderIdentifier?: string | undefined, referenceIdentifier?: string | undefined, referenceIdentifier2?: string | undefined, referenceIdentifier3?: string | undefined, referenceIdentifier4?: string | undefined, referenceIdentifier5?: string | undefined, shipmentTags?: Array | undefined, customsInfo?: RequestCustomsInfo | undefined, orderedDateTime?: string | undefined, packages: Array, partnerShipmentId?: string | undefined, shipiumShipmentId?: string | undefined}; export type Units = {currencyCode: string, linearUnit: 'in' | 'cm', weightUnit: 'g' | 'kg' | 'oz' | 'lb'}; export type LtlCostRequest = {businessDaysOfTransit?: number | undefined, currencyCode?: string | undefined, desiredDeliveryDate?: string | undefined, desiredDeliveryDateOptions?: DesiredDeliveryDateOptions | undefined, destinationAddress: CSAddress, existingShipmentIds?: Array | undefined, includeEvaluatedServiceMethodsInResponse?: boolean | undefined, includeLineItemsInEvaluatedServiceMethods?: boolean | undefined, ltlShipmentParameters: LtlShipmentParameters, packedShipments?: Array | undefined, partnerLtlCostId?: string | undefined, returnToAddress?: CSAddress | undefined, shipFromAddress: CSAddress, shippedDateTime?: string | undefined, shipments?: Array | undefined, tenantId?: string | undefined, testMode?: boolean | undefined, units?: Units | undefined}; export type CreateApiApiV1LtlShipmentCostArgs = {body: LtlCostRequest}; export type CreateApiApiV1LtlShipmentCostOptions = {baseUrl?: string | undefined, oauth2Scheme?: string | undefined, fetch?: typeof fetch | undefined}; 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 units = z.object({currencyCode: z.string(), linearUnit: z.enum(["in", "cm"]), weightUnit: z.enum(["g", "kg", "oz", "lb"])}); export const ltlCostSummary = z.object({transportationType: z.enum(["ltlTransportation", "packageTransportation"]), transportationTypeCost: z.number()}); export const currencyAmount = z.object({amount: z.number(), currency: z.string().optional()}); export const loadPackagingSize = z.object({height: z.number(), length: z.number(), linearUnit: z.enum(["in", "cm"]).optional(), weight: z.number(), weightUnit: z.enum(["g", "kg", "oz", "lb"]).optional(), width: z.number()}); export const loadPackagingDetails = z.object({declaredValue: currencyAmount.optional(), loadPackagingType: z.enum(["loose", "overboxed", "piece", "wrapped", "pallet"]).optional(), loadPackagingSize: loadPackagingSize, nmfcFreightClass: z.string()}); export const ltlLoadPackagingItem = z.object({partnerShipmentId: z.string().optional(), shipiumShipmentId: z.string().optional(), packageReferenceIdentifier: z.string().optional()}); export const ltlLoadPackagingRecommendation = z.object({details: loadPackagingDetails, shipments: z.array(ltlLoadPackagingItem).optional()}); export const weight = z.object({weightUnit: z.enum(["g", "kg", "oz", "lb"]).optional(), weight: z.number().optional()}); export const ltlRateLineItem = z.object({name: z.string(), rate: z.number(), carrierSurchargeId: z.string().optional(), surchargeType: z.enum(["additional_handling_weight", "additional_handling_volume", "additional_handling_length", "additional_handling_extra_length", "additional_handling_width", "additional_handling_packaging", "alaska_delivery_commercial_air", "alaska_delivery_commercial_ground", "alaska_delivery_residential_air", "alaska_delivery_residential_ground", "base", "delivery_commercial_air", "delivery_commercial_ground", "delivery_residential_air", "delivery_residential_ground", "extended_delivery_commercial_air", "extended_delivery_commercial_ground", "extended_delivery_residential_air", "extended_delivery_residential_ground", "fuel_air_domestic", "fuel_air_international_export", "fuel_air_international_import", "fuel_ground", "hawaii_delivery_commercial_air", "hawaii_delivery_commercial_ground", "hawaii_delivery_residential_air", "hawaii_delivery_residential_ground", "hazmat", "incentive", "international_delivery_area", "international_extended_delivery_area", "large_package_commercial", "large_package_residential", "peak", "peak_additional_handling", "peak_residential_delivery_air", "peak_residential_delivery_ground", "peak_large_package", "remote_delivery_commercial_air", "remote_delivery_commercial_ground", "remote_delivery_residential_air", "remote_delivery_residential_ground", "residential_air", "residential_ground", "saturday_delivery", "signature", "signature_resident", "signature_adult", "signature_adult_resident", "surcharge", "zone_weight"]).optional(), lineItemType: z.string().optional(), hiddenFromCarrierCompare: z.boolean().optional(), hiddenFromInvoice: z.boolean().optional(), hiddenFromOperational: z.boolean().optional(), nmfcFreightClass: z.string().optional(), weight: weight.optional()}); export const ltlLoadDeficitCost = z.object({amount: z.number(), nmfcClass: z.string().optional(), weight: weight, rate: z.number()}); export const ltlCarrierCost = z.object({billableWeight: weight, billToThirdPartyId: z.string().optional(), carrier: z.string(), carrierAccountId: z.string().optional(), carrierServiceMethodId: z.string(), estimatedDeliveryDate: z.string().optional(), lineItems: z.array(ltlRateLineItem).optional(), loadDeficitCost: ltlLoadDeficitCost.optional(), pickupDateTime: z.string().optional(), pricingType: z.enum(["all", "contract", "contractPallet", "dynamic", "volume", "unknown"]).optional(), quoteId: z.string().optional(), quoteEffectiveDateTime: z.string().optional(), quoteExpirationDateTime: z.string().optional(), scacCode: z.string(), serviceLevel: z.enum(["all", "guaranteedMorning", "guaranteedNoon", "guaranteedEndOfDay", "standard", "unknown"]), totalCost: z.number().optional()}); export const ltlCarrierSelection = z.object({loadPackaging: z.array(ltlLoadPackagingRecommendation), evaluatedCarriers: z.array(ltlCarrierCost).optional(), selectedCarrier: ltlCarrierCost.optional(), totalCost: z.number().optional()}); export const ltlBillToContact = z.object({addressLineComponents: addressLineComponents.optional(), addressType: z.enum(["commercial", "residential"]).optional(), city: z.string().optional(), company: z.string().optional(), countryCode: z.string(), emailAddress: z.string().optional(), name: z.string().optional(), phoneNumber: z.string().optional(), phoneNumberCountryCode: z.string().optional(), postalCode: z.string(), state: z.string().optional(), street1: z.string().optional(), street2: z.string().optional(), thirdPartyBillingSetId: z.string()}); export const ltlHazmatContact = z.object({contactName: z.string(), phoneNumber: z.string(), phoneNumberCountryCode: z.string().optional(), email: z.string().optional()}); export const loadPackagingSizeRequest = z.object({height: z.number(), length: z.number(), linearUnit: z.enum(["in", "cm"]).optional(), maximumWeight: z.number().optional(), packagingWeight: z.number().optional(), weightUnit: z.enum(["g", "kg", "oz", "lb"]).optional(), width: z.number()}); export const loadPackagingDetailsRequest = z.object({loadPackagingType: z.enum(["loose", "overboxed", "piece", "wrapped", "pallet"]).optional(), loadPackagingSize: loadPackagingSizeRequest}); export const ltlPaymentDetails = z.object({payerType: z.enum(["consignee", "shipper", "thirdParty"]), paymentTerms: z.enum(["collect", "prePaid", "thirdParty"])}); export const ltlShipmentParameters = z.object({billToContact: ltlBillToContact.optional(), carrierServiceMethodAllowList: z.array(z.string()).optional(), collectOnDelivery: currencyAmount.optional(), fulfillmentContextIds: z.array(z.string()).optional(), originId: z.string().optional(), fulfillmentType: z.enum(["customer", "at_large", "returns", "hundredweight", "reship", "unknown"]).optional(), hazmatContact: ltlHazmatContact.optional(), packagingOptions: z.array(loadPackagingDetailsRequest).optional(), paymentDetails: ltlPaymentDetails, pickupDate: z.string(), pricingTypes: z.array(z.enum(["all", "contract", "contractPallet", "dynamic", "volume", "unknown"])).optional(), serviceLevels: z.array(z.enum(["all", "guaranteedMorning", "guaranteedNoon", "guaranteedEndOfDay", "standard", "unknown"])).optional(), accessorialCodes: z.array(z.enum(["AIRD", "AIRP", "APTD", "APTP", "CFSD", "CFSP", "COD", "FSC", "GTD", "HAZ", "HCDA", "HCPA", "INS", "LTDAD", "LTDAP", "MISC", "MNC", "OVR", "PPD", "PSN", "REP", "RES", "SLTDAD", "SLTDAP", "SS", "WGDL", "WGDU"])).optional()}); export const injectionSummary = z.object({requestInjectionProfileId: z.string().optional(), partnerInjectionProfileId: z.string().optional(), shipiumInjectionProfileId: z.string().optional(), requestInjectionSiteId: z.string().optional(), partnerInjectionSiteId: z.string().optional(), shipiumInjectionSiteId: z.string().optional()}); export const cubicVolume = z.object({cubicVolumeUnit: z.enum(["in", "ft", "cm", "m"]).optional(), cubicVolume: z.number().optional()}); export const laneMatch = z.object({laneId: z.string().optional(), partnerLaneId: z.string().optional()}); export const injectionRateModifier = z.object({modifierType: z.enum(["flat", "percentage"]).optional(), modifierValue: z.number().optional()}); export const injectionCostDetails = z.object({injectionLineItemRate: z.number().optional(), injectionLineItemCurrencyCode: z.string().optional(), injectionRateModifier: injectionRateModifier.optional()}); export const injectionDetails = z.object({requestInjectionProfileId: z.string().optional(), partnerInjectionProfileId: z.string().optional(), shipiumInjectionProfileId: z.string().optional(), requestInjectionSiteId: z.string().optional(), partnerInjectionSiteId: z.string().optional(), shipiumInjectionSiteId: z.string().optional(), injectionCostDetails: injectionCostDetails.optional()}); export const rateLineItem = z.object({name: z.string(), rate: z.number(), carrierSurchargeId: z.string().optional(), surchargeType: z.enum(["additional_handling_weight", "additional_handling_volume", "additional_handling_length", "additional_handling_extra_length", "additional_handling_width", "additional_handling_packaging", "alaska_delivery_commercial_air", "alaska_delivery_commercial_ground", "alaska_delivery_residential_air", "alaska_delivery_residential_ground", "base", "delivery_commercial_air", "delivery_commercial_ground", "delivery_residential_air", "delivery_residential_ground", "extended_delivery_commercial_air", "extended_delivery_commercial_ground", "extended_delivery_residential_air", "extended_delivery_residential_ground", "fuel_air_domestic", "fuel_air_international_export", "fuel_air_international_import", "fuel_ground", "hawaii_delivery_commercial_air", "hawaii_delivery_commercial_ground", "hawaii_delivery_residential_air", "hawaii_delivery_residential_ground", "hazmat", "incentive", "international_delivery_area", "international_extended_delivery_area", "large_package_commercial", "large_package_residential", "peak", "peak_additional_handling", "peak_residential_delivery_air", "peak_residential_delivery_ground", "peak_large_package", "remote_delivery_commercial_air", "remote_delivery_commercial_ground", "remote_delivery_residential_air", "remote_delivery_residential_ground", "residential_air", "residential_ground", "saturday_delivery", "signature", "signature_resident", "signature_adult", "signature_adult_resident", "surcharge", "zone_weight"]).optional(), lineItemType: z.string().optional(), hiddenFromCarrierCompare: z.boolean().optional(), hiddenFromInvoice: z.boolean().optional(), hiddenFromOperational: z.boolean().optional()}); export const carrierSelectionExpansion = z.object({carrier: z.string().optional(), carrierServiceMethodId: z.string().optional(), serviceMethodName: z.string().optional(), carrierAccountId: z.string().optional(), totalCost: z.number().optional(), estimatedDeliveryDate: z.string().optional(), injectionDetails: injectionDetails.optional(), rateCurrency: z.string().optional(), lineItems: z.array(rateLineItem).optional(), estimatedDeliveryDateLocal: z.string().optional()}); export const carrierSelectionSummary = z.object({status: z.enum(["success", "uncosted", "no_decision"]).optional(), statusDetails: z.string().optional(), carrierSelectionId: z.string().optional(), shipiumShipmentId: z.string().optional(), partnerShipmentId: z.string().optional(), partnerId: z.string().optional(), carrierAccountId: z.string().optional(), serviceMethodUrn: z.string().optional(), serviceMethodIdentifier: z.string().optional(), carrier: z.string().optional(), carrierServiceMethodId: z.string().optional(), serviceMethodName: z.string().optional(), costAdjustConfigId: z.string().optional(), totalCost: z.number().optional(), carrierCompareCost: z.number().optional(), carrierInvoiceCost: z.number().optional(), operationalCost: z.number().optional(), thirdPartyBilling: z.boolean().optional(), carrierSelectionDateTime: z.string().optional(), injectionDetails: injectionSummary.optional(), carrierZoneId: z.string().optional(), calculatedBillableWeight: weight.optional(), calculatedBillableCubicVolume: cubicVolume.optional(), laneMatch: laneMatch.optional(), evaluatedServiceMethods: z.array(carrierSelectionExpansion).optional(), cancellationDateTime: z.string().optional(), effectiveShipDateTime: z.string().optional(), currencyCode: z.string().optional()}); export const ltlParcelCarrierSelection = z.object({totalCost: z.number(), packageDetails: z.array(carrierSelectionSummary), status: z.enum(["success", "failure", "timeout"])}); export const timeWindow = z.object({startWindow: z.string(), endWindow: z.string(), timeZone: z.string().optional()}); export const injectionParameter = z.object({injectionProfileId: z.string().optional(), injectionSiteId: z.string().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 ltlParcelShipmentParameters = z.object({carrierServiceMethodAllowList: z.array(z.string()).optional(), deliverySignatureOption: z.enum(["None", "Signature", "ResidentSignature", "AdultSignature", "AdultResidentSignature", "Unknown"]).optional(), deliveryWindow: timeWindow.optional(), forceThirdPartyBilling: z.boolean().optional(), fulfillmentContextIds: z.array(z.string()).optional(), originId: z.string().optional(), fulfillmentType: z.enum(["customer", "at_large", "returns", "hundredweight", "reship", "unknown"]).optional(), ignoreCarrierMinimumDimensions: z.boolean().optional(), ignoreUpgradeSpendLimits: z.boolean().optional(), includeInjectionProfiles: z.boolean().optional(), injectionParameters: z.array(injectionParameter).optional(), lastMileDeliveryOptions: lastMileDeliveryOptions.optional(), pickupWindow: timeWindow.optional(), preferredCarrierDeliveryDateTime: z.string().optional(), saturdayDelivery: z.boolean().optional(), desktopDelivery: z.boolean().optional(), serviceMethodPoBoxAllowList: z.array(z.string()).optional(), shipOption: z.string().optional(), thirdPartyBillingSetId: z.string().optional()}); export const ltlShipmentItemSummary = z.object({partnerShipmentId: z.string().optional(), shipiumShipmentId: z.string().optional()}); export const ltlCostResponse = z.object({shipiumLtlCostId: z.string(), partnerLtlCostId: z.string().optional(), partnerTenantId: z.string().optional(), shipiumTenantId: z.string().optional(), shipFromAddress: cSAddress, shipFromTimeZoneId: z.string().optional(), destinationAddress: cSAddress, destinationTimeZoneId: z.string().optional(), returnToAddress: cSAddress.optional(), rawDesiredDeliveryDate: z.string().optional(), recommendedTransportationType: z.enum(["ltlTransportation", "packageTransportation"]), recommendedTransportationTypeCost: z.number(), testMode: z.boolean(), currencyCode: z.string().optional(), units: units.optional(), allTransportationTypeCosts: z.array(ltlCostSummary), ltlCostDetails: ltlCarrierSelection, ltlShipmentParameters: ltlShipmentParameters, packageCostDetails: ltlParcelCarrierSelection.optional(), packageShipmentParameters: ltlParcelShipmentParameters.optional(), packedShipments: z.array(loadPackagingDetails).optional(), shipments: z.array(ltlShipmentItemSummary).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 }; /** * Retrieve the cost for a LTL shipment. * * POST /api/v1/ltl/shipment/cost */ export const createApiApiV1LtlShipmentCost = async (args: CreateApiApiV1LtlShipmentCostArgs, options?: CreateApiApiV1LtlShipmentCostOptions) => { 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/ltl/shipment/cost${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(ltlCostResponse, await res.json()) };