/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; 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"; /** * To have insurance cover provided by a carrier directly instead of Shippo's provider (XCover), set provider to `FEDEX`, `UPS`, or `ONTRAC`. */ export const ParcelInsuranceProvider = { Fedex: "FEDEX", Ups: "UPS", Ontrac: "ONTRAC", } as const; /** * To have insurance cover provided by a carrier directly instead of Shippo's provider (XCover), set provider to `FEDEX`, `UPS`, or `ONTRAC`. */ export type ParcelInsuranceProvider = ClosedEnum< typeof ParcelInsuranceProvider >; /** * 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. */ export type ParcelInsurance = { /** * Declared value of the goods you want to insure. */ amount?: string | undefined; /** * Description of parcel content. */ content?: string | undefined; /** * Currency for the amount value. Currently only USD is supported for FedEx and UPS. */ currency?: string | undefined; /** * To have insurance cover provided by a carrier directly instead of Shippo's provider (XCover), set provider to `FEDEX`, `UPS`, or `ONTRAC`. */ provider?: ParcelInsuranceProvider | undefined; }; /** @internal */ export const ParcelInsuranceProvider$inboundSchema: z.ZodMiniEnum< typeof ParcelInsuranceProvider > = z.enum(ParcelInsuranceProvider); /** @internal */ export const ParcelInsuranceProvider$outboundSchema: z.ZodMiniEnum< typeof ParcelInsuranceProvider > = ParcelInsuranceProvider$inboundSchema; /** @internal */ export const ParcelInsurance$inboundSchema: z.ZodMiniType< ParcelInsurance, unknown > = z.object({ amount: z.optional(z.string()), content: z.optional(z.string()), currency: z.optional(z.string()), provider: z.optional(ParcelInsuranceProvider$inboundSchema), }); /** @internal */ export type ParcelInsurance$Outbound = { amount?: string | undefined; content?: string | undefined; currency?: string | undefined; provider?: string | undefined; }; /** @internal */ export const ParcelInsurance$outboundSchema: z.ZodMiniType< ParcelInsurance$Outbound, ParcelInsurance > = z.object({ amount: z.optional(z.string()), content: z.optional(z.string()), currency: z.optional(z.string()), provider: z.optional(ParcelInsuranceProvider$outboundSchema), }); export function parcelInsuranceToJSON( parcelInsurance: ParcelInsurance, ): string { return JSON.stringify(ParcelInsurance$outboundSchema.parse(parcelInsurance)); } export function parcelInsuranceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ParcelInsurance$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ParcelInsurance' from JSON`, ); }