/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod/v3"; import { safeParse } from "../../lib/schemas.js"; import { Decimal as Decimal$ } from "../../types/decimal.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"; /** * Details of a specific interchange program fee. */ export type BillingInterchangeProgramFee = { /** * The name of the interchange program. */ programName: string; /** * The number of transactions for this program. */ count: number; /** * The percentage rate for this program. */ percentageRate: Decimal$ | number; /** * The per-item rate for this program. */ perItemRate: AmountDecimal; /** * The total fee amount for this program. */ total: AmountDecimal; /** * The total transfer volume for this program. */ transferVolume: AmountDecimal; }; /** @internal */ export const BillingInterchangeProgramFee$inboundSchema: z.ZodType< BillingInterchangeProgramFee, z.ZodTypeDef, unknown > = z.object({ programName: z.string(), count: z.number().int(), percentageRate: z.number().transform(v => new Decimal$(v)), perItemRate: AmountDecimal$inboundSchema, total: AmountDecimal$inboundSchema, transferVolume: AmountDecimal$inboundSchema, }); /** @internal */ export type BillingInterchangeProgramFee$Outbound = { programName: string; count: number; percentageRate: number; perItemRate: AmountDecimal$Outbound; total: AmountDecimal$Outbound; transferVolume: AmountDecimal$Outbound; }; /** @internal */ export const BillingInterchangeProgramFee$outboundSchema: z.ZodType< BillingInterchangeProgramFee$Outbound, z.ZodTypeDef, BillingInterchangeProgramFee > = z.object({ programName: z.string(), count: z.number().int(), percentageRate: z.union([z.instanceof(Decimal$), z.number()]).transform(v => typeof v === "number" ? v : v.toNumber() ), perItemRate: AmountDecimal$outboundSchema, total: AmountDecimal$outboundSchema, transferVolume: AmountDecimal$outboundSchema, }); export function billingInterchangeProgramFeeToJSON( billingInterchangeProgramFee: BillingInterchangeProgramFee, ): string { return JSON.stringify( BillingInterchangeProgramFee$outboundSchema.parse( billingInterchangeProgramFee, ), ); } export function billingInterchangeProgramFeeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BillingInterchangeProgramFee$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BillingInterchangeProgramFee' from JSON`, ); }