/* * 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 { ProductImageMetadata, ProductImageMetadata$inboundSchema, ProductImageMetadata$Outbound, ProductImageMetadata$outboundSchema, } from "./productimagemetadata.js"; /** * Represents a single product option within a group. */ export type ProductOption = { /** * The display name of a product option. */ name: string; /** * A detailed description of the option. * * @remarks * * - Must be valid UTF-8 text * - Supports Markdown for formatting * - HTML is not permitted and will be rejected */ description?: string | undefined; /** * The adjustment applied to a product's base price by this option. Can be negative, positive, or zero. */ priceModifier?: AmountDecimal | undefined; /** * The images associated with this option. */ images?: Array | undefined; }; /** @internal */ export const ProductOption$inboundSchema: z.ZodType< ProductOption, z.ZodTypeDef, unknown > = z.object({ name: z.string(), description: z.string().optional(), priceModifier: AmountDecimal$inboundSchema.optional(), images: z.array(ProductImageMetadata$inboundSchema).optional(), }); /** @internal */ export type ProductOption$Outbound = { name: string; description?: string | undefined; priceModifier?: AmountDecimal$Outbound | undefined; images?: Array | undefined; }; /** @internal */ export const ProductOption$outboundSchema: z.ZodType< ProductOption$Outbound, z.ZodTypeDef, ProductOption > = z.object({ name: z.string(), description: z.string().optional(), priceModifier: AmountDecimal$outboundSchema.optional(), images: z.array(ProductImageMetadata$outboundSchema).optional(), }); export function productOptionToJSON(productOption: ProductOption): string { return JSON.stringify(ProductOption$outboundSchema.parse(productOption)); } export function productOptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ProductOption$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ProductOption' from JSON`, ); }