/* * 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 { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.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"; /** * The type of the credit being issued */ export enum TransfersCreditCreateType { TypeUnspecified = "TYPE_UNSPECIFIED", Promotional = "PROMOTIONAL", WriteOff = "WRITE_OFF", Reimbursement = "REIMBURSEMENT", } /** * The type of the credit being issued */ export type TransfersCreditCreateTypeOpen = OpenEnum< typeof TransfersCreditCreateType >; /** * A transfer using the CREDIT mechanism. Funds are moved from a firm account to a customer's brokerage account */ export type TransfersCreditCreate = { /** * 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; /** * External identifier supplied by the API caller. Each request must have a unique pairing of client_transfer_id and account */ clientTransferId: string; /** * Optional description information that will attach to this transaction */ description?: string | undefined; /** * Optional account field to denote where the credit amount should be withdrawn from. If provided, the account must be a fee operating account. In the case of multiple fee operating accounts under the same correspondent, this field must be provided. If not provided, this will be looked up asynchronously (therefore will not be in the initial response) */ feeOperatingAccount?: string | undefined; /** * The type of the credit being issued */ type: TransfersCreditCreateTypeOpen; }; /** @internal */ export const TransfersCreditCreateType$inboundSchema: z.ZodType< TransfersCreditCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TransfersCreditCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TransfersCreditCreateType$outboundSchema: z.ZodType< TransfersCreditCreateTypeOpen, z.ZodTypeDef, TransfersCreditCreateTypeOpen > = z.union([ z.nativeEnum(TransfersCreditCreateType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TransfersCreditCreateType$ { /** @deprecated use `TransfersCreditCreateType$inboundSchema` instead. */ export const inboundSchema = TransfersCreditCreateType$inboundSchema; /** @deprecated use `TransfersCreditCreateType$outboundSchema` instead. */ export const outboundSchema = TransfersCreditCreateType$outboundSchema; } /** @internal */ export const TransfersCreditCreate$inboundSchema: z.ZodType< TransfersCreditCreate, z.ZodTypeDef, unknown > = z.object({ amount: DecimalCreate$inboundSchema, client_transfer_id: z.string(), description: z.string().optional(), fee_operating_account: z.string().optional(), type: TransfersCreditCreateType$inboundSchema, }).transform((v) => { return remap$(v, { "client_transfer_id": "clientTransferId", "fee_operating_account": "feeOperatingAccount", }); }); /** @internal */ export type TransfersCreditCreate$Outbound = { amount: DecimalCreate$Outbound; client_transfer_id: string; description?: string | undefined; fee_operating_account?: string | undefined; type: string; }; /** @internal */ export const TransfersCreditCreate$outboundSchema: z.ZodType< TransfersCreditCreate$Outbound, z.ZodTypeDef, TransfersCreditCreate > = z.object({ amount: DecimalCreate$outboundSchema, clientTransferId: z.string(), description: z.string().optional(), feeOperatingAccount: z.string().optional(), type: TransfersCreditCreateType$outboundSchema, }).transform((v) => { return remap$(v, { clientTransferId: "client_transfer_id", feeOperatingAccount: "fee_operating_account", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TransfersCreditCreate$ { /** @deprecated use `TransfersCreditCreate$inboundSchema` instead. */ export const inboundSchema = TransfersCreditCreate$inboundSchema; /** @deprecated use `TransfersCreditCreate$outboundSchema` instead. */ export const outboundSchema = TransfersCreditCreate$outboundSchema; /** @deprecated use `TransfersCreditCreate$Outbound` instead. */ export type Outbound = TransfersCreditCreate$Outbound; } export function transfersCreditCreateToJSON( transfersCreditCreate: TransfersCreditCreate, ): string { return JSON.stringify( TransfersCreditCreate$outboundSchema.parse(transfersCreditCreate), ); } export function transfersCreditCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersCreditCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersCreditCreate' from JSON`, ); }