/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * An object representing a discount applied to an ecommerce order or product. */ export type EcommerceDiscount = { /** * The code used to apply the discount. */ code?: string | null | undefined; /** * The fixed amount of the discount. */ amount?: string | null | undefined; /** * The percentage of the discount. */ percentage?: string | null | undefined; }; /** @internal */ export const EcommerceDiscount$inboundSchema: z.ZodType< EcommerceDiscount, z.ZodTypeDef, unknown > = z.object({ code: z.nullable(z.string()).optional(), amount: z.nullable(z.string()).optional(), percentage: z.nullable(z.string()).optional(), }); /** @internal */ export type EcommerceDiscount$Outbound = { code?: string | null | undefined; amount?: string | null | undefined; percentage?: string | null | undefined; }; /** @internal */ export const EcommerceDiscount$outboundSchema: z.ZodType< EcommerceDiscount$Outbound, z.ZodTypeDef, EcommerceDiscount > = z.object({ code: z.nullable(z.string()).optional(), amount: z.nullable(z.string()).optional(), percentage: z.nullable(z.string()).optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace EcommerceDiscount$ { /** @deprecated use `EcommerceDiscount$inboundSchema` instead. */ export const inboundSchema = EcommerceDiscount$inboundSchema; /** @deprecated use `EcommerceDiscount$outboundSchema` instead. */ export const outboundSchema = EcommerceDiscount$outboundSchema; /** @deprecated use `EcommerceDiscount$Outbound` instead. */ export type Outbound = EcommerceDiscount$Outbound; } export function ecommerceDiscountToJSON( ecommerceDiscount: EcommerceDiscount, ): string { return JSON.stringify( EcommerceDiscount$outboundSchema.parse(ecommerceDiscount), ); } export function ecommerceDiscountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceDiscount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceDiscount' from JSON`, ); }