/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v4-mini"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { DiscountDuration, DiscountDuration$inboundSchema, DiscountDuration$outboundSchema, } from "./discountduration.js"; import { DiscountType, DiscountType$inboundSchema, DiscountType$outboundSchema, } from "./discounttype.js"; /** * Schema for a percentage discount that is applied once or forever. */ export type CheckoutDiscountPercentageOnceForeverDuration = { duration: DiscountDuration; type: DiscountType; /** * Discount percentage in basis points. A basis point is 1/100th of a percent. For example, 1000 basis points equals a 10% discount. */ basisPoints: number; /** * The ID of the object. */ id: string; name: string; code: string | null; }; /** @internal */ export const CheckoutDiscountPercentageOnceForeverDuration$inboundSchema: z.ZodMiniType = z .pipe( z.object({ duration: DiscountDuration$inboundSchema, type: DiscountType$inboundSchema, basis_points: z.int(), id: z.string(), name: z.string(), code: z.nullable(z.string()), }), z.transform((v) => { return remap$(v, { "basis_points": "basisPoints", }); }), ); /** @internal */ export type CheckoutDiscountPercentageOnceForeverDuration$Outbound = { duration: string; type: string; basis_points: number; id: string; name: string; code: string | null; }; /** @internal */ export const CheckoutDiscountPercentageOnceForeverDuration$outboundSchema: z.ZodMiniType< CheckoutDiscountPercentageOnceForeverDuration$Outbound, CheckoutDiscountPercentageOnceForeverDuration > = z.pipe( z.object({ duration: DiscountDuration$outboundSchema, type: DiscountType$outboundSchema, basisPoints: z.int(), id: z.string(), name: z.string(), code: z.nullable(z.string()), }), z.transform((v) => { return remap$(v, { basisPoints: "basis_points", }); }), ); export function checkoutDiscountPercentageOnceForeverDurationToJSON( checkoutDiscountPercentageOnceForeverDuration: CheckoutDiscountPercentageOnceForeverDuration, ): string { return JSON.stringify( CheckoutDiscountPercentageOnceForeverDuration$outboundSchema.parse( checkoutDiscountPercentageOnceForeverDuration, ), ); } export function checkoutDiscountPercentageOnceForeverDurationFromJSON( jsonString: string, ): SafeParseResult< CheckoutDiscountPercentageOnceForeverDuration, SDKValidationError > { return safeParse( jsonString, (x) => CheckoutDiscountPercentageOnceForeverDuration$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CheckoutDiscountPercentageOnceForeverDuration' from JSON`, ); }