/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { remap as remap$ } from "../../lib/primitives.js"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { DecimalCreate, DecimalCreate$inboundSchema, DecimalCreate$Outbound, DecimalCreate$outboundSchema, } from "./decimalcreate.js"; import { RetirementDistributionCreate, RetirementDistributionCreate$inboundSchema, RetirementDistributionCreate$Outbound, RetirementDistributionCreate$outboundSchema, } from "./retirementdistributioncreate.js"; /** * A withdrawal transfer using the ACH mechanism. */ export type AchWithdrawalCreate = { /** * A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java's [BigDecimal][] or Python's [decimal.Decimal][]. * * @remarks * * [BigDecimal]: * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html * [decimal.Decimal]: https://docs.python.org/3/library/decimal.html */ amount?: DecimalCreate | undefined; /** * The bank relationship to be used for the ACH withdrawal. */ bankRelationship: string; /** * The external identifier supplied by the API caller. Each request must have a unique pairing of `client_transfer_id` and `account`. */ clientTransferId: string; /** * Whether the entire account balance is being withdrawn. Must not be true if the `amount` is specified. */ fullDisbursement?: boolean | undefined; /** * The memo that will appear on the customer's bank statement. */ memo?: string | undefined; /** * A distribution from a retirement account. */ retirementDistribution?: RetirementDistributionCreate | undefined; }; /** @internal */ export const AchWithdrawalCreate$inboundSchema: z.ZodType< AchWithdrawalCreate, z.ZodTypeDef, unknown > = z.object({ amount: DecimalCreate$inboundSchema.optional(), bank_relationship: z.string(), client_transfer_id: z.string(), full_disbursement: z.boolean().optional(), memo: z.string().optional(), retirement_distribution: RetirementDistributionCreate$inboundSchema .optional(), }).transform((v) => { return remap$(v, { "bank_relationship": "bankRelationship", "client_transfer_id": "clientTransferId", "full_disbursement": "fullDisbursement", "retirement_distribution": "retirementDistribution", }); }); /** @internal */ export type AchWithdrawalCreate$Outbound = { amount?: DecimalCreate$Outbound | undefined; bank_relationship: string; client_transfer_id: string; full_disbursement?: boolean | undefined; memo?: string | undefined; retirement_distribution?: RetirementDistributionCreate$Outbound | undefined; }; /** @internal */ export const AchWithdrawalCreate$outboundSchema: z.ZodType< AchWithdrawalCreate$Outbound, z.ZodTypeDef, AchWithdrawalCreate > = z.object({ amount: DecimalCreate$outboundSchema.optional(), bankRelationship: z.string(), clientTransferId: z.string(), fullDisbursement: z.boolean().optional(), memo: z.string().optional(), retirementDistribution: RetirementDistributionCreate$outboundSchema .optional(), }).transform((v) => { return remap$(v, { bankRelationship: "bank_relationship", clientTransferId: "client_transfer_id", fullDisbursement: "full_disbursement", retirementDistribution: "retirement_distribution", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AchWithdrawalCreate$ { /** @deprecated use `AchWithdrawalCreate$inboundSchema` instead. */ export const inboundSchema = AchWithdrawalCreate$inboundSchema; /** @deprecated use `AchWithdrawalCreate$outboundSchema` instead. */ export const outboundSchema = AchWithdrawalCreate$outboundSchema; /** @deprecated use `AchWithdrawalCreate$Outbound` instead. */ export type Outbound = AchWithdrawalCreate$Outbound; } export function achWithdrawalCreateToJSON( achWithdrawalCreate: AchWithdrawalCreate, ): string { return JSON.stringify( AchWithdrawalCreate$outboundSchema.parse(achWithdrawalCreate), ); } export function achWithdrawalCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AchWithdrawalCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AchWithdrawalCreate' from JSON`, ); }