/* * 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 { PaymentLinkLineItemImageMetadata, PaymentLinkLineItemImageMetadata$inboundSchema, PaymentLinkLineItemImageMetadata$Outbound, PaymentLinkLineItemImageMetadata$outboundSchema, } from "./paymentlinklineitemimagemetadata.js"; import { PaymentLinkLineItemOption, PaymentLinkLineItemOption$inboundSchema, PaymentLinkLineItemOption$Outbound, PaymentLinkLineItemOption$outboundSchema, } from "./paymentlinklineitemoption.js"; /** * Represents a single line item in a payment link, including optional modifiers and quantity. */ export type PaymentLinkLineItem = { /** * 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 PaymentLinkLineItem$inboundSchema: z.ZodType< PaymentLinkLineItem, z.ZodTypeDef, unknown > = z.object({ name: z.string(), basePrice: AmountDecimal$inboundSchema, quantity: z.number().int(), options: z.array(PaymentLinkLineItemOption$inboundSchema).optional(), images: z.array(PaymentLinkLineItemImageMetadata$inboundSchema).optional(), productID: z.string().optional(), }); /** @internal */ export type PaymentLinkLineItem$Outbound = { name: string; basePrice: AmountDecimal$Outbound; quantity: number; options?: Array | undefined; images?: Array | undefined; productID?: string | undefined; }; /** @internal */ export const PaymentLinkLineItem$outboundSchema: z.ZodType< PaymentLinkLineItem$Outbound, z.ZodTypeDef, PaymentLinkLineItem > = z.object({ name: z.string(), basePrice: AmountDecimal$outboundSchema, quantity: z.number().int(), options: z.array(PaymentLinkLineItemOption$outboundSchema).optional(), images: z.array(PaymentLinkLineItemImageMetadata$outboundSchema).optional(), productID: z.string().optional(), }); export function paymentLinkLineItemToJSON( paymentLinkLineItem: PaymentLinkLineItem, ): string { return JSON.stringify( PaymentLinkLineItem$outboundSchema.parse(paymentLinkLineItem), ); } export function paymentLinkLineItemFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentLinkLineItem$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentLinkLineItem' from JSON`, ); }