/* * 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 Provider = { 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 Provider = ClosedEnum; /** * To add 3rd party insurance powered by XCover, * * @remarks * specify
`amount`, `content`, and `currency`.
Alternatively, you can choose carrier provided insurance * by additionally specifying `provider` (UPS, FedEx and OnTrac only).

If you do not want to add insurance * to your shipment, do not set these parameters. */ export type Insurance = { /** * Declared value of the goods you want to insure. */ amount?: string | undefined; /** * Description of package content. */ content?: string | undefined; /** * Currency for the amount value. * * @remarks * 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?: Provider | undefined; }; /** @internal */ export const Provider$inboundSchema: z.ZodMiniEnum = z.enum( Provider, ); /** @internal */ export const Provider$outboundSchema: z.ZodMiniEnum = Provider$inboundSchema; /** @internal */ export const Insurance$inboundSchema: z.ZodMiniType = z .object({ amount: z.optional(z.string()), content: z.optional(z.string()), currency: z.optional(z.string()), provider: z.optional(Provider$inboundSchema), }); /** @internal */ export type Insurance$Outbound = { amount?: string | undefined; content?: string | undefined; currency?: string | undefined; provider?: string | undefined; }; /** @internal */ export const Insurance$outboundSchema: z.ZodMiniType< Insurance$Outbound, Insurance > = z.object({ amount: z.optional(z.string()), content: z.optional(z.string()), currency: z.optional(z.string()), provider: z.optional(Provider$outboundSchema), }); export function insuranceToJSON(insurance: Insurance): string { return JSON.stringify(Insurance$outboundSchema.parse(insurance)); } export function insuranceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Insurance$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Insurance' from JSON`, ); }