/* * 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"; /** * Represents a modifier or option applied to a line item. */ export type PaymentLinkLineItemOption = { /** * The name of the option or modifier. */ name: string; /** * The quantity of this option. */ quantity: number; /** * Optional price modification applied by this option. Can be positive, negative, or zero. */ priceModifier?: AmountDecimal | undefined; /** * Optional list of images associated with this line item option. */ images?: Array | undefined; /** * Optional group identifier to categorize related options (e.g., 'toppings'). */ group?: string | undefined; }; /** @internal */ export const PaymentLinkLineItemOption$inboundSchema: z.ZodType< PaymentLinkLineItemOption, z.ZodTypeDef, unknown > = z.object({ name: z.string(), quantity: z.number().int(), priceModifier: AmountDecimal$inboundSchema.optional(), images: z.array(PaymentLinkLineItemImageMetadata$inboundSchema).optional(), group: z.string().optional(), }); /** @internal */ export type PaymentLinkLineItemOption$Outbound = { name: string; quantity: number; priceModifier?: AmountDecimal$Outbound | undefined; images?: Array | undefined; group?: string | undefined; }; /** @internal */ export const PaymentLinkLineItemOption$outboundSchema: z.ZodType< PaymentLinkLineItemOption$Outbound, z.ZodTypeDef, PaymentLinkLineItemOption > = z.object({ name: z.string(), quantity: z.number().int(), priceModifier: AmountDecimal$outboundSchema.optional(), images: z.array(PaymentLinkLineItemImageMetadata$outboundSchema).optional(), group: z.string().optional(), }); export function paymentLinkLineItemOptionToJSON( paymentLinkLineItemOption: PaymentLinkLineItemOption, ): string { return JSON.stringify( PaymentLinkLineItemOption$outboundSchema.parse(paymentLinkLineItemOption), ); } export function paymentLinkLineItemOptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PaymentLinkLineItemOption$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PaymentLinkLineItemOption' from JSON`, ); }