/* * 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 { DangerousGoodsBiologicalMaterial, DangerousGoodsBiologicalMaterial$inboundSchema, DangerousGoodsBiologicalMaterial$Outbound, DangerousGoodsBiologicalMaterial$outboundSchema, } from "./dangerousgoodsbiologicalmaterial.js"; import { DangerousGoodsLithiumBatteries, DangerousGoodsLithiumBatteries$inboundSchema, DangerousGoodsLithiumBatteries$Outbound, DangerousGoodsLithiumBatteries$outboundSchema, } from "./dangerousgoodslithiumbatteries.js"; /** * Container for specifying the presence of dangerous materials. This is specific to USPS, and if any contents * * @remarks * are provided, only certain USPS service levels will be eligible. For more information, see our * guide on hazardous or dangerous materials shipping. */ export type DangerousGoodsObject = { /** * Indicates if the shipment contains dangerous goods. */ contains?: boolean | undefined; /** * Container for specifying the presence of biological material. */ biologicalMaterial?: DangerousGoodsBiologicalMaterial | undefined; /** * Container for specifying the presence of lithium batteries. */ lithiumBatteries?: DangerousGoodsLithiumBatteries | undefined; }; /** @internal */ export const DangerousGoodsObject$inboundSchema: z.ZodMiniType< DangerousGoodsObject, unknown > = z.pipe( z.object({ contains: z.optional(z.boolean()), biological_material: z.optional( DangerousGoodsBiologicalMaterial$inboundSchema, ), lithium_batteries: z.optional(DangerousGoodsLithiumBatteries$inboundSchema), }), z.transform((v) => { return remap$(v, { "biological_material": "biologicalMaterial", "lithium_batteries": "lithiumBatteries", }); }), ); /** @internal */ export type DangerousGoodsObject$Outbound = { contains?: boolean | undefined; biological_material?: DangerousGoodsBiologicalMaterial$Outbound | undefined; lithium_batteries?: DangerousGoodsLithiumBatteries$Outbound | undefined; }; /** @internal */ export const DangerousGoodsObject$outboundSchema: z.ZodMiniType< DangerousGoodsObject$Outbound, DangerousGoodsObject > = z.pipe( z.object({ contains: z.optional(z.boolean()), biologicalMaterial: z.optional( DangerousGoodsBiologicalMaterial$outboundSchema, ), lithiumBatteries: z.optional(DangerousGoodsLithiumBatteries$outboundSchema), }), z.transform((v) => { return remap$(v, { biologicalMaterial: "biological_material", lithiumBatteries: "lithium_batteries", }); }), ); export function dangerousGoodsObjectToJSON( dangerousGoodsObject: DangerousGoodsObject, ): string { return JSON.stringify( DangerousGoodsObject$outboundSchema.parse(dangerousGoodsObject), ); } export function dangerousGoodsObjectFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => DangerousGoodsObject$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'DangerousGoodsObject' from JSON`, ); }