/* * 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 { SweepStatus, SweepStatus$inboundSchema, SweepStatus$outboundSchema, } from "./sweepstatus.js"; import { SweepSubtotal, SweepSubtotal$inboundSchema, SweepSubtotal$Outbound, SweepSubtotal$outboundSchema, } from "./sweepsubtotal.js"; export type Sweep = { sweepID: string; status: SweepStatus; /** * The total net amount of wallet transactions accrued in the sweep. */ accruedAmount: string; /** * Amount remaining in the wallet after the sweep transfer completes. */ residualBalance?: string | undefined; /** * A 3-letter ISO 4217 currency code. */ currency: string; /** * The date-time the sweep began accruing transactions. */ accrualStartedOn: Date; /** * The date-time the sweep stopped accruing transactions. */ accrualEndedOn?: Date | undefined; /** * ID of the payment method. */ pushPaymentMethodID?: string | undefined; /** * ID of the payment method. */ pullPaymentMethodID?: string | undefined; transferID?: string | undefined; /** * Amount that is transferred. */ transferAmount?: string | undefined; /** * The text that appears on the banking statement. The default descriptor is a 10 character ID if an override is not set in the sweep configs statementDescriptor. */ statementDescriptor?: string | undefined; /** * The subtotal of each transaction type contributing to the sweep's accrued amount. */ subtotals?: Array | undefined; }; /** @internal */ export const Sweep$inboundSchema: z.ZodType = z .object({ sweepID: z.string(), status: SweepStatus$inboundSchema, accruedAmount: z.string(), residualBalance: z.string().optional(), currency: z.string(), accrualStartedOn: z.string().datetime({ offset: true }).transform(v => new Date(v) ), accrualEndedOn: z.string().datetime({ offset: true }).transform(v => new Date(v) ).optional(), pushPaymentMethodID: z.string().optional(), pullPaymentMethodID: z.string().optional(), transferID: z.string().optional(), transferAmount: z.string().optional(), statementDescriptor: z.string().optional(), subtotals: z.array(SweepSubtotal$inboundSchema).optional(), }); /** @internal */ export type Sweep$Outbound = { sweepID: string; status: string; accruedAmount: string; residualBalance?: string | undefined; currency: string; accrualStartedOn: string; accrualEndedOn?: string | undefined; pushPaymentMethodID?: string | undefined; pullPaymentMethodID?: string | undefined; transferID?: string | undefined; transferAmount?: string | undefined; statementDescriptor?: string | undefined; subtotals?: Array | undefined; }; /** @internal */ export const Sweep$outboundSchema: z.ZodType< Sweep$Outbound, z.ZodTypeDef, Sweep > = z.object({ sweepID: z.string(), status: SweepStatus$outboundSchema, accruedAmount: z.string(), residualBalance: z.string().optional(), currency: z.string(), accrualStartedOn: z.date().transform(v => v.toISOString()), accrualEndedOn: z.date().transform(v => v.toISOString()).optional(), pushPaymentMethodID: z.string().optional(), pullPaymentMethodID: z.string().optional(), transferID: z.string().optional(), transferAmount: z.string().optional(), statementDescriptor: z.string().optional(), subtotals: z.array(SweepSubtotal$outboundSchema).optional(), }); export function sweepToJSON(sweep: Sweep): string { return JSON.stringify(Sweep$outboundSchema.parse(sweep)); } export function sweepFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Sweep$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Sweep' from JSON`, ); }