/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { AmountDecimal, AmountDecimal$inboundSchema, AmountDecimal$Outbound, AmountDecimal$outboundSchema, } from "./amountdecimal.js"; import { TransferLineItemImageMetadata, TransferLineItemImageMetadata$inboundSchema, TransferLineItemImageMetadata$Outbound, TransferLineItemImageMetadata$outboundSchema, } from "./transferlineitemimagemetadata.js"; import { TransferLineItemOption, TransferLineItemOption$inboundSchema, TransferLineItemOption$Outbound, TransferLineItemOption$outboundSchema, } from "./transferlineitemoption.js"; /** * Represents a single item in a transfer, including optional modifiers and quantity. */ export type TransferLineItem = { /** * The name of the item. */ name: string; /** * The base price of the item before applying option modifiers. */ basePrice: AmountDecimal; /** * The quantity of this item. */ quantity: number; /** * Optional list of modifiers applied to this item (e.g., toppings, upgrades, customizations). */ options?: Array | undefined; /** * Optional list of images associated with this line item. */ images?: Array | undefined; /** * Optional unique identifier associating the line item with a product. */ productID?: string | undefined; }; /** @internal */ export const TransferLineItem$inboundSchema: z.ZodType< TransferLineItem, z.ZodTypeDef, unknown > = z.object({ name: z.string(), basePrice: AmountDecimal$inboundSchema, quantity: z.number().int(), options: z.array(TransferLineItemOption$inboundSchema).optional(), images: z.array(TransferLineItemImageMetadata$inboundSchema).optional(), productID: z.string().optional(), }); /** @internal */ export type TransferLineItem$Outbound = { name: string; basePrice: AmountDecimal$Outbound; quantity: number; options?: Array | undefined; images?: Array | undefined; productID?: string | undefined; }; /** @internal */ export const TransferLineItem$outboundSchema: z.ZodType< TransferLineItem$Outbound, z.ZodTypeDef, TransferLineItem > = z.object({ name: z.string(), basePrice: AmountDecimal$outboundSchema, quantity: z.number().int(), options: z.array(TransferLineItemOption$outboundSchema).optional(), images: z.array(TransferLineItemImageMetadata$outboundSchema).optional(), productID: z.string().optional(), }); export function transferLineItemToJSON( transferLineItem: TransferLineItem, ): string { return JSON.stringify( TransferLineItem$outboundSchema.parse(transferLineItem), ); } export function transferLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransferLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransferLineItem' from JSON`, ); }