/* * 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"; /** * Defines the volume ranges for tiered pricing models. */ export type VolumeRange = { /** * Specifies the lower value of a tier for the fee. */ fromValue: number; /** * Specifies the upper value of a tier for the fee. */ toValue?: number | undefined; /** * The flat amount for a whole tier of the fee. */ flatAmount: AmountDecimal; /** * The unit price for a specific tier of the fee. */ perUnitAmount: AmountDecimal; }; /** @internal */ export const VolumeRange$inboundSchema: z.ZodType< VolumeRange, z.ZodTypeDef, unknown > = z.object({ fromValue: z.number().int(), toValue: z.number().int().optional(), flatAmount: AmountDecimal$inboundSchema, perUnitAmount: AmountDecimal$inboundSchema, }); /** @internal */ export type VolumeRange$Outbound = { fromValue: number; toValue?: number | undefined; flatAmount: AmountDecimal$Outbound; perUnitAmount: AmountDecimal$Outbound; }; /** @internal */ export const VolumeRange$outboundSchema: z.ZodType< VolumeRange$Outbound, z.ZodTypeDef, VolumeRange > = z.object({ fromValue: z.number().int(), toValue: z.number().int().optional(), flatAmount: AmountDecimal$outboundSchema, perUnitAmount: AmountDecimal$outboundSchema, }); export function volumeRangeToJSON(volumeRange: VolumeRange): string { return JSON.stringify(VolumeRange$outboundSchema.parse(volumeRange)); } export function volumeRangeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => VolumeRange$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'VolumeRange' from JSON`, ); }