/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { ObjectStateEnum, ObjectStateEnum$inboundSchema, } from "./objectstateenum.js"; import { WeightUnitEnum, WeightUnitEnum$inboundSchema, } from "./weightunitenum.js"; export type CustomsItem = { /** * Text description of your item. */ description: string; /** * Export Control Classification Number, required on some exports from the United States. */ eccnEar99?: string | undefined; /** * The unit used for weight. */ massUnit: WeightUnitEnum; /** * 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; /** * Total weight of this item, i.e. quantity * weight per item. */ netWeight: string; /** * Country of origin of the item. Example: `US` or `DE`. * * @remarks * All accepted values can be found on the Official ISO Website. */ originCountry: string; /** * Quantity of this item in the shipment you send. Must be greater than 0. */ quantity: number; /** * SKU code of the item, which is required by some carriers. */ skuCode?: string | undefined; /** * HS code of the item, which is required by some carriers. If `tariff_number` is not provided, `hs_code` will be used. If both `hs_code` and `tariff_number` are provided, `tariff_number` will be used. 50 character limit. */ hsCode?: string | undefined; /** * The tariff number of the item. If `tariff_number` is not provided, `hs_code` will be used. If both `hs_code` and `tariff_number` are provided, `tariff_number` will be used. 12 character limit. */ tariffNumber?: string | undefined; /** * Total value of this item, i.e. quantity * value per item. */ valueAmount: string; /** * Currency used for value_amount. The official ISO 4217 * * @remarks * currency codes are used, e.g. `USD` or `EUR`. */ valueCurrency: 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 CustomsItem$inboundSchema: z.ZodMiniType = z .pipe( z.object({ description: z.string(), eccn_ear99: z.optional(z.string()), mass_unit: WeightUnitEnum$inboundSchema, metadata: z.optional(z.string()), net_weight: z.string(), origin_country: z.string(), quantity: z.int(), sku_code: z.optional(z.string()), hs_code: z.optional(z.string()), tariff_number: z.optional(z.string()), value_amount: z.string(), value_currency: 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, { "eccn_ear99": "eccnEar99", "mass_unit": "massUnit", "net_weight": "netWeight", "origin_country": "originCountry", "sku_code": "skuCode", "hs_code": "hsCode", "tariff_number": "tariffNumber", "value_amount": "valueAmount", "value_currency": "valueCurrency", "object_created": "objectCreated", "object_id": "objectId", "object_owner": "objectOwner", "object_state": "objectState", "object_updated": "objectUpdated", }); }), ); export function customsItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CustomsItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CustomsItem' from JSON`, ); }