/* * 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 { Cod, Cod$inboundSchema, Cod$Outbound, Cod$outboundSchema, } from "./cod.js"; import { ParcelInsurance, ParcelInsurance$inboundSchema, ParcelInsurance$Outbound, ParcelInsurance$outboundSchema, } from "./parcelinsurance.js"; /** * An object holding optional extra services to be requested for each parcel in a multi-piece shipment. * * @remarks * See the Parcel Extra table below for all available services. */ export type ParcelExtra = { /** * Specify collection on delivery details (UPS only). */ cod?: Cod | undefined; /** * To add insurance to your parcel, specify `amount`, `content` and `currency`.

If you do not want to add insurance to you parcel, do not set these parameters. */ insurance?: ParcelInsurance | undefined; /** * Optional text to be printed on the shipping label if supported by carrier. Up to 50 characters. */ reference1?: string | undefined; /** * Optional text to be printed on the shipping label if supported by carrier. Up to 50 characters. */ reference2?: string | undefined; }; /** @internal */ export const ParcelExtra$inboundSchema: z.ZodMiniType = z .pipe( z.object({ COD: z.optional(Cod$inboundSchema), insurance: z.optional(ParcelInsurance$inboundSchema), reference_1: z.optional(z.string()), reference_2: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { "COD": "cod", "reference_1": "reference1", "reference_2": "reference2", }); }), ); /** @internal */ export type ParcelExtra$Outbound = { COD?: Cod$Outbound | undefined; insurance?: ParcelInsurance$Outbound | undefined; reference_1?: string | undefined; reference_2?: string | undefined; }; /** @internal */ export const ParcelExtra$outboundSchema: z.ZodMiniType< ParcelExtra$Outbound, ParcelExtra > = z.pipe( z.object({ cod: z.optional(Cod$outboundSchema), insurance: z.optional(ParcelInsurance$outboundSchema), reference1: z.optional(z.string()), reference2: z.optional(z.string()), }), z.transform((v) => { return remap$(v, { cod: "COD", reference1: "reference_1", reference2: "reference_2", }); }), ); export function parcelExtraToJSON(parcelExtra: ParcelExtra): string { return JSON.stringify(ParcelExtra$outboundSchema.parse(parcelExtra)); } export function parcelExtraFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ParcelExtra$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ParcelExtra' from JSON`, ); }