/* * 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 { RetirementContributionCreate, RetirementContributionCreate$inboundSchema, RetirementContributionCreate$Outbound, RetirementContributionCreate$outboundSchema, } from "./retirementcontributioncreate.js"; import { RetirementDistributionCreate, RetirementDistributionCreate$inboundSchema, RetirementDistributionCreate$Outbound, RetirementDistributionCreate$outboundSchema, } from "./retirementdistributioncreate.js"; /** * A cash journal transfer. Funds are moved from a source account to a destination account */ export type CashJournalCreate = { /** * 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 external identifier supplied by the API caller Each request must have a unique pairing of `client_transfer_id` and `source_account` */ clientTransferId: string; /** * The account that funds will be moved to */ destinationAccount: string; /** * Whether the entire source account balance is being withdrawn Must not be true if the `amount` is specified */ fullDisbursement?: boolean | undefined; /** * A contribution to a retirement account. */ retirementContribution?: RetirementContributionCreate | undefined; /** * A distribution from a retirement account. */ retirementDistribution?: RetirementDistributionCreate | undefined; /** * The account that funds will be moved from */ sourceAccount: string; }; /** @internal */ export const CashJournalCreate$inboundSchema: z.ZodType< CashJournalCreate, z.ZodTypeDef, unknown > = z.object({ amount: DecimalCreate$inboundSchema.optional(), client_transfer_id: z.string(), destination_account: z.string(), full_disbursement: z.boolean().optional(), retirement_contribution: RetirementContributionCreate$inboundSchema .optional(), retirement_distribution: RetirementDistributionCreate$inboundSchema .optional(), source_account: z.string(), }).transform((v) => { return remap$(v, { "client_transfer_id": "clientTransferId", "destination_account": "destinationAccount", "full_disbursement": "fullDisbursement", "retirement_contribution": "retirementContribution", "retirement_distribution": "retirementDistribution", "source_account": "sourceAccount", }); }); /** @internal */ export type CashJournalCreate$Outbound = { amount?: DecimalCreate$Outbound | undefined; client_transfer_id: string; destination_account: string; full_disbursement?: boolean | undefined; retirement_contribution?: RetirementContributionCreate$Outbound | undefined; retirement_distribution?: RetirementDistributionCreate$Outbound | undefined; source_account: string; }; /** @internal */ export const CashJournalCreate$outboundSchema: z.ZodType< CashJournalCreate$Outbound, z.ZodTypeDef, CashJournalCreate > = z.object({ amount: DecimalCreate$outboundSchema.optional(), clientTransferId: z.string(), destinationAccount: z.string(), fullDisbursement: z.boolean().optional(), retirementContribution: RetirementContributionCreate$outboundSchema .optional(), retirementDistribution: RetirementDistributionCreate$outboundSchema .optional(), sourceAccount: z.string(), }).transform((v) => { return remap$(v, { clientTransferId: "client_transfer_id", destinationAccount: "destination_account", fullDisbursement: "full_disbursement", retirementContribution: "retirement_contribution", retirementDistribution: "retirement_distribution", sourceAccount: "source_account", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CashJournalCreate$ { /** @deprecated use `CashJournalCreate$inboundSchema` instead. */ export const inboundSchema = CashJournalCreate$inboundSchema; /** @deprecated use `CashJournalCreate$outboundSchema` instead. */ export const outboundSchema = CashJournalCreate$outboundSchema; /** @deprecated use `CashJournalCreate$Outbound` instead. */ export type Outbound = CashJournalCreate$Outbound; } export function cashJournalCreateToJSON( cashJournalCreate: CashJournalCreate, ): string { return JSON.stringify( CashJournalCreate$outboundSchema.parse(cashJournalCreate), ); } export function cashJournalCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CashJournalCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CashJournalCreate' from JSON`, ); }