/* * 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 { AssignProductImage, AssignProductImage$inboundSchema, AssignProductImage$Outbound, AssignProductImage$outboundSchema, } from "./assignproductimage.js"; export type CreateProductOption = { /** * 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; /** * Assign previously uploaded images to a product or option. */ images?: Array | undefined; }; /** @internal */ export const CreateProductOption$inboundSchema: z.ZodType< CreateProductOption, z.ZodTypeDef, unknown > = z.object({ name: z.string(), description: z.string().optional(), priceModifier: AmountDecimal$inboundSchema.optional(), images: z.array(AssignProductImage$inboundSchema).optional(), }); /** @internal */ export type CreateProductOption$Outbound = { name: string; description?: string | undefined; priceModifier?: AmountDecimal$Outbound | undefined; images?: Array | undefined; }; /** @internal */ export const CreateProductOption$outboundSchema: z.ZodType< CreateProductOption$Outbound, z.ZodTypeDef, CreateProductOption > = z.object({ name: z.string(), description: z.string().optional(), priceModifier: AmountDecimal$outboundSchema.optional(), images: z.array(AssignProductImage$outboundSchema).optional(), }); export function createProductOptionToJSON( createProductOption: CreateProductOption, ): string { return JSON.stringify( CreateProductOption$outboundSchema.parse(createProductOption), ); } export function createProductOptionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CreateProductOption$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateProductOption' from JSON`, ); }