/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AddressReferenceInput, AddressReferenceInput$inboundSchema, AddressReferenceInput$Outbound, AddressReferenceInput$outboundSchema, } from "./addressreferenceinput.js"; import { Amount, Amount$inboundSchema, Amount$Outbound, Amount$outboundSchema, } from "./amount.js"; export type CartShipment = { address?: AddressReferenceInput | undefined; /** * A monetary amount, i.e. a base unit amount and a supported currency. */ cost?: Amount | undefined; /** * The name of the carrier selected. */ carrier?: string | undefined; }; /** @internal */ export const CartShipment$inboundSchema: z.ZodType< CartShipment, z.ZodTypeDef, unknown > = z.object({ address: AddressReferenceInput$inboundSchema.optional(), cost: Amount$inboundSchema.optional(), carrier: z.string().optional(), }); /** @internal */ export type CartShipment$Outbound = { address?: AddressReferenceInput$Outbound | undefined; cost?: Amount$Outbound | undefined; carrier?: string | undefined; }; /** @internal */ export const CartShipment$outboundSchema: z.ZodType< CartShipment$Outbound, z.ZodTypeDef, CartShipment > = z.object({ address: AddressReferenceInput$outboundSchema.optional(), cost: Amount$outboundSchema.optional(), carrier: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CartShipment$ { /** @deprecated use `CartShipment$inboundSchema` instead. */ export const inboundSchema = CartShipment$inboundSchema; /** @deprecated use `CartShipment$outboundSchema` instead. */ export const outboundSchema = CartShipment$outboundSchema; /** @deprecated use `CartShipment$Outbound` instead. */ export type Outbound = CartShipment$Outbound; } export function cartShipmentToJSON(cartShipment: CartShipment): string { return JSON.stringify(CartShipment$outboundSchema.parse(cartShipment)); } export function cartShipmentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CartShipment$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CartShipment' from JSON`, ); }