/* * 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 { WalletAvailableBalance, WalletAvailableBalance$inboundSchema, WalletAvailableBalance$Outbound, WalletAvailableBalance$outboundSchema, } from "./walletavailablebalance.js"; import { WalletStatus, WalletStatus$inboundSchema, WalletStatus$outboundSchema, } from "./walletstatus.js"; import { WalletType, WalletType$inboundSchema, WalletType$outboundSchema, } from "./wallettype.js"; /** * A Moov wallet to store funds for transfers. */ export type Wallet = { walletID: string; availableBalance: WalletAvailableBalance; partnerAccountID: string; /** * Name of the wallet */ name: string; /** * Status of a wallet. * * @remarks * - `active`: The wallet is available for use and has an enabled payment method. * - `closed`: The wallet is no longer active and the corresponding payment method has been disabled. */ status: WalletStatus; /** * Type of a wallet. * * @remarks * - `default`: The system-generated wallet automatically created when an account is granted the wallet capability. * - `general`: An additional, user-defined wallet created via API or Dashboard. */ walletType: WalletType; /** * Description of the wallet */ description: string; /** * Free-form key-value pair list. Useful for storing information that is not captured elsewhere. */ metadata?: { [k: string]: string } | undefined; createdOn: Date; closedOn?: Date | undefined; }; /** @internal */ export const Wallet$inboundSchema: z.ZodType = z .object({ walletID: z.string(), availableBalance: WalletAvailableBalance$inboundSchema, partnerAccountID: z.string(), name: z.string(), status: WalletStatus$inboundSchema, walletType: WalletType$inboundSchema, description: z.string(), metadata: z.record(z.string()).optional(), createdOn: z.string().datetime({ offset: true }).transform(v => new Date(v) ), closedOn: z.string().datetime({ offset: true }).transform(v => new Date(v)) .optional(), }); /** @internal */ export type Wallet$Outbound = { walletID: string; availableBalance: WalletAvailableBalance$Outbound; partnerAccountID: string; name: string; status: string; walletType: string; description: string; metadata?: { [k: string]: string } | undefined; createdOn: string; closedOn?: string | undefined; }; /** @internal */ export const Wallet$outboundSchema: z.ZodType< Wallet$Outbound, z.ZodTypeDef, Wallet > = z.object({ walletID: z.string(), availableBalance: WalletAvailableBalance$outboundSchema, partnerAccountID: z.string(), name: z.string(), status: WalletStatus$outboundSchema, walletType: WalletType$outboundSchema, description: z.string(), metadata: z.record(z.string()).optional(), createdOn: z.date().transform(v => v.toISOString()), closedOn: z.date().transform(v => v.toISOString()).optional(), }); export function walletToJSON(wallet: Wallet): string { return JSON.stringify(Wallet$outboundSchema.parse(wallet)); } export function walletFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Wallet$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Wallet' from JSON`, ); }