/* * 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 on every invoice * * @remarks * for a certain number of months. */ export type CheckoutDiscountPercentageRepeatDuration = { duration: DiscountDuration; durationInMonths: number; 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 CheckoutDiscountPercentageRepeatDuration$inboundSchema: z.ZodMiniType = z.pipe( z.object({ duration: DiscountDuration$inboundSchema, duration_in_months: z.int(), type: DiscountType$inboundSchema, basis_points: z.int(), id: z.string(), name: z.string(), code: z.nullable(z.string()), }), z.transform((v) => { return remap$(v, { "duration_in_months": "durationInMonths", "basis_points": "basisPoints", }); }), ); /** @internal */ export type CheckoutDiscountPercentageRepeatDuration$Outbound = { duration: string; duration_in_months: number; type: string; basis_points: number; id: string; name: string; code: string | null; }; /** @internal */ export const CheckoutDiscountPercentageRepeatDuration$outboundSchema: z.ZodMiniType< CheckoutDiscountPercentageRepeatDuration$Outbound, CheckoutDiscountPercentageRepeatDuration > = z.pipe( z.object({ duration: DiscountDuration$outboundSchema, durationInMonths: z.int(), type: DiscountType$outboundSchema, basisPoints: z.int(), id: z.string(), name: z.string(), code: z.nullable(z.string()), }), z.transform((v) => { return remap$(v, { durationInMonths: "duration_in_months", basisPoints: "basis_points", }); }), ); export function checkoutDiscountPercentageRepeatDurationToJSON( checkoutDiscountPercentageRepeatDuration: CheckoutDiscountPercentageRepeatDuration, ): string { return JSON.stringify( CheckoutDiscountPercentageRepeatDuration$outboundSchema.parse( checkoutDiscountPercentageRepeatDuration, ), ); } export function checkoutDiscountPercentageRepeatDurationFromJSON( jsonString: string, ): SafeParseResult< CheckoutDiscountPercentageRepeatDuration, SDKValidationError > { return safeParse( jsonString, (x) => CheckoutDiscountPercentageRepeatDuration$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CheckoutDiscountPercentageRepeatDuration' from JSON`, ); }