/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { ClosedEnum } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { CustomsExporterIdentification, CustomsExporterIdentification$inboundSchema, } from "./customsexporteridentification.js"; import { CustomsInvoicedCharges, CustomsInvoicedCharges$inboundSchema, } from "./customsinvoicedcharges.js"; import { ObjectStateEnum, ObjectStateEnum$inboundSchema, } from "./objectstateenum.js"; /** * Party to be billed for duties. */ export const CustomsDeclarationType = { Sender: "SENDER", Recipient: "RECIPIENT", ThirdParty: "THIRD_PARTY", } as const; /** * Party to be billed for duties. */ export type CustomsDeclarationType = ClosedEnum; export type CustomsDeclarationAddress = { /** * Name of the party to be billed for duties. */ name?: string | undefined; /** * Postal code of the party to be billed for duties. */ zip?: string | undefined; /** * Country ISO code of account number to be billed. */ country?: string | undefined; }; /** * Specifies who will pay the duties for the shipment. Only accepted for FedEx shipments. */ export type CustomsDeclarationDutiesPayor = { /** * Account number to be billed for duties. */ account?: string | undefined; /** * Party to be billed for duties. */ type?: CustomsDeclarationType | undefined; address?: CustomsDeclarationAddress | undefined; }; export type CustomsDeclaration = { /** * **required if eel_pfc is `AES_ITN`**
* * @remarks * AES / ITN reference of the shipment. */ aesItn?: string | undefined; /** * B13A Option details are obtained by filing a B13A Canada Export Declaration via the Canadian Export Reporting System (CERS). * * @remarks * More information on reporting commercial exports from Canada. * Allowed values available here */ b13aFilingOption?: string | undefined; /** * **must be provided if and only if b13a_filing_option is provided**
* * @remarks * Represents:
the Proof of Report (POR) Number when b13a_filing_option is `FILED_ELECTRONICALLY`;
* the Summary ID Number when b13a_filing_option is `SUMMARY_REPORTING`;
* or the Exemption Number when b13a_filing_option is `NOT_REQUIRED`. */ b13aNumber?: string | undefined; /** * Certificate reference of the shipment. */ certificate?: string | undefined; /** * Expresses that the certify_signer has provided all information of this customs declaration truthfully. */ certify: boolean; /** * Name of the person who created the customs declaration and is responsible for the validity of all * * @remarks * information provided. */ certifySigner: string; commercialInvoice?: boolean | undefined; /** * **required if contents_type is `OTHER`**
* * @remarks * Explanation of the type of goods of the shipment. */ contentsExplanation?: string | undefined; /** * Disclaimer for the shipment and customs information that have been provided. */ disclaimer?: string | undefined; /** * Specifies who will pay the duties for the shipment. Only accepted for FedEx shipments. */ dutiesPayor?: CustomsDeclarationDutiesPayor | undefined; /** * Additional exporter identification that may be required to ship in certain countries */ exporterIdentification?: CustomsExporterIdentification | undefined; /** * Exporter reference of an export shipment. */ exporterReference?: string | undefined; /** * Importer reference of an import shipment. */ importerReference?: string | undefined; /** * Indicates whether the shipment's destination VAT has been collected. May be required for some destinations. */ isVatCollected?: boolean | undefined; /** * Invoice reference of the shipment. */ invoice?: string | undefined; /** * License reference of the shipment. */ license?: string | undefined; /** * A string of up to 100 characters that can be filled with any additional information you * * @remarks * want to attach to the object. */ metadata?: string | undefined; /** * Additional notes to be included in the customs declaration. */ notes?: string | undefined; /** * Object ID of the Importer address. */ addressImporter?: string | undefined; /** * Type of goods of the shipment. * * @remarks * Allowed values available here */ contentsType: string; /** * EEL / PFC type of the shipment. For most shipments from the US to CA, `NOEEI_30_36` is applicable; for most * * @remarks * other shipments from the US, `NOEEI_30_37_a` is applicable. * Allowed values available here */ eelPfc?: string | undefined; /** * The incoterm reference of the shipment. FCA is available for DHL Express and FedEx only. * * @remarks * eDAP is available for DPD UK only. DAP is available for DHL Express and DPD UK. * If expecting DAP for other carriers, please use DDU. * Allowed values available here */ incoterm?: string | undefined; /** * Additional invoiced charges to be shown on the Customs Declaration Commercial Invoice. */ invoicedCharges?: CustomsInvoicedCharges | undefined; /** * Distinct Parcel content items as Customs Items object_ids. */ items: Array; /** * Indicates how the carrier should proceed in case the shipment can't be delivered. * * @remarks * Allowed values available here */ nonDeliveryOption: string; /** * Date and time of object creation. */ objectCreated?: Date | undefined; /** * Unique identifier of the given object. */ objectId?: string | undefined; /** * Username of the user who created the object. */ objectOwner?: string | undefined; /** * Indicates the validity of the enclosing object */ objectState?: ObjectStateEnum | undefined; /** * Date and time of last object update. */ objectUpdated?: Date | undefined; /** * Indicates whether the object has been created in test mode. */ test?: boolean | undefined; }; /** @internal */ export const CustomsDeclarationType$inboundSchema: z.ZodMiniEnum< typeof CustomsDeclarationType > = z.enum(CustomsDeclarationType); /** @internal */ export const CustomsDeclarationAddress$inboundSchema: z.ZodMiniType< CustomsDeclarationAddress, unknown > = z.object({ name: z.optional(z.string()), zip: z.optional(z.string()), country: z.optional(z.string()), }); export function customsDeclarationAddressFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomsDeclarationAddress$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomsDeclarationAddress' from JSON`, ); } /** @internal */ export const CustomsDeclarationDutiesPayor$inboundSchema: z.ZodMiniType< CustomsDeclarationDutiesPayor, unknown > = z.object({ account: z.optional(z.string()), type: z.optional(CustomsDeclarationType$inboundSchema), address: z.optional(z.lazy(() => CustomsDeclarationAddress$inboundSchema)), }); export function customsDeclarationDutiesPayorFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomsDeclarationDutiesPayor$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomsDeclarationDutiesPayor' from JSON`, ); } /** @internal */ export const CustomsDeclaration$inboundSchema: z.ZodMiniType< CustomsDeclaration, unknown > = z.pipe( z.object({ aes_itn: z.optional(z.string()), b13a_filing_option: z.optional(z.string()), b13a_number: z.optional(z.string()), certificate: z.optional(z.string()), certify: z.boolean(), certify_signer: z.string(), commercial_invoice: z.optional(z.boolean()), contents_explanation: z.optional(z.string()), disclaimer: z.optional(z.string()), duties_payor: z.optional( z.lazy(() => CustomsDeclarationDutiesPayor$inboundSchema), ), exporter_identification: z.optional( CustomsExporterIdentification$inboundSchema, ), exporter_reference: z.optional(z.string()), importer_reference: z.optional(z.string()), is_vat_collected: z.optional(z.boolean()), invoice: z.optional(z.string()), license: z.optional(z.string()), metadata: z.optional(z.string()), notes: z.optional(z.string()), address_importer: z.optional(z.string()), contents_type: z.string(), eel_pfc: z.optional(z.string()), incoterm: z.optional(z.string()), invoiced_charges: z.optional(CustomsInvoicedCharges$inboundSchema), items: z.array(z.string()), non_delivery_option: z.string(), object_created: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), object_id: z.optional(z.string()), object_owner: z.optional(z.string()), object_state: z.optional(ObjectStateEnum$inboundSchema), object_updated: z.optional( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), test: z.optional(z.boolean()), }), z.transform((v) => { return remap$(v, { "aes_itn": "aesItn", "b13a_filing_option": "b13aFilingOption", "b13a_number": "b13aNumber", "certify_signer": "certifySigner", "commercial_invoice": "commercialInvoice", "contents_explanation": "contentsExplanation", "duties_payor": "dutiesPayor", "exporter_identification": "exporterIdentification", "exporter_reference": "exporterReference", "importer_reference": "importerReference", "is_vat_collected": "isVatCollected", "address_importer": "addressImporter", "contents_type": "contentsType", "eel_pfc": "eelPfc", "invoiced_charges": "invoicedCharges", "non_delivery_option": "nonDeliveryOption", "object_created": "objectCreated", "object_id": "objectId", "object_owner": "objectOwner", "object_state": "objectState", "object_updated": "objectUpdated", }); }), ); export function customsDeclarationFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomsDeclaration$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomsDeclaration' from JSON`, ); }