/* * 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"; export type Amount = { /** * A 3-letter ISO 4217 currency code. */ currency: string; /** * Quantity in the smallest unit of the specified currency. * * @remarks * * In USD this is cents, for example, $12.04 is 1204 and $0.99 is 99. */ value: number; }; /** @internal */ export const Amount$inboundSchema: z.ZodType = z .object({ currency: z.string(), value: z.number().int(), }); /** @internal */ export type Amount$Outbound = { currency: string; value: number; }; /** @internal */ export const Amount$outboundSchema: z.ZodType< Amount$Outbound, z.ZodTypeDef, Amount > = z.object({ currency: z.string(), value: z.number().int(), }); export function amountToJSON(amount: Amount): string { return JSON.stringify(Amount$outboundSchema.parse(amount)); } export function amountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Amount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Amount' from JSON`, ); }