/* * 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 { CreateTransferLineItemOption, CreateTransferLineItemOption$inboundSchema, CreateTransferLineItemOption$Outbound, CreateTransferLineItemOption$outboundSchema, } from "./createtransferlineitemoption.js"; /** * Represents a single item in a transfer, including optional modifiers and quantity. */ export type CreateTransferLineItem = { /** * 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. */ imageIDs?: Array | undefined; /** * Optional unique identifier associating the line item with a product. */ productID?: string | undefined; }; /** @internal */ export const CreateTransferLineItem$inboundSchema: z.ZodType< CreateTransferLineItem, z.ZodTypeDef, unknown > = z.object({ name: z.string(), basePrice: AmountDecimal$inboundSchema, quantity: z.number().int(), options: z.array(CreateTransferLineItemOption$inboundSchema).optional(), imageIDs: z.array(z.string()).optional(), productID: z.string().optional(), }); /** @internal */ export type CreateTransferLineItem$Outbound = { name: string; basePrice: AmountDecimal$Outbound; quantity: number; options?: Array | undefined; imageIDs?: Array | undefined; productID?: string | undefined; }; /** @internal */ export const CreateTransferLineItem$outboundSchema: z.ZodType< CreateTransferLineItem$Outbound, z.ZodTypeDef, CreateTransferLineItem > = z.object({ name: z.string(), basePrice: AmountDecimal$outboundSchema, quantity: z.number().int(), options: z.array(CreateTransferLineItemOption$outboundSchema).optional(), imageIDs: z.array(z.string()).optional(), productID: z.string().optional(), }); export function createTransferLineItemToJSON( createTransferLineItem: CreateTransferLineItem, ): string { return JSON.stringify( CreateTransferLineItem$outboundSchema.parse(createTransferLineItem), ); } export function createTransferLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateTransferLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateTransferLineItem' from JSON`, ); }