/* * 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"; /** * The amount of the credit being issued to the investor */ export type TransfersCreditAmount = { /** * The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details */ value?: string | undefined; }; /** * The high level state of a transfer, one of: * * @remarks * - `PROCESSING` - The transfer is being processed and will be posted if successful. * - `PENDING_REVIEW` - The transfer is pending review and will continue processing if approved. * - `POSTED` - The transfer has been posted to the ledger and will be completed at the end of the processing window if not canceled first. * - `COMPLETED` - The transfer has been batched and completed. * - `REJECTED` - The transfer was rejected. * - `CANCELED` - The transfer was canceled. * - `RETURNED` - The transfer was returned. * - `POSTPONED` - The transfer is postponed and will resume processing during the next processing window. */ export enum TransfersCreditStateState { StateUnspecified = "STATE_UNSPECIFIED", Processing = "PROCESSING", PendingReview = "PENDING_REVIEW", Posted = "POSTED", Completed = "COMPLETED", Rejected = "REJECTED", Canceled = "CANCELED", Returned = "RETURNED", Postponed = "POSTPONED", } /** * The high level state of a transfer, one of: * * @remarks * - `PROCESSING` - The transfer is being processed and will be posted if successful. * - `PENDING_REVIEW` - The transfer is pending review and will continue processing if approved. * - `POSTED` - The transfer has been posted to the ledger and will be completed at the end of the processing window if not canceled first. * - `COMPLETED` - The transfer has been batched and completed. * - `REJECTED` - The transfer was rejected. * - `CANCELED` - The transfer was canceled. * - `RETURNED` - The transfer was returned. * - `POSTPONED` - The transfer is postponed and will resume processing during the next processing window. */ export type TransfersCreditStateStateOpen = OpenEnum< typeof TransfersCreditStateState >; /** * The current state of the credit */ export type TransfersCreditState = { /** * The user or service that triggered the state update. */ actor?: string | undefined; /** * Additional description of the transfer state. */ message?: string | undefined; /** * Additional metadata relating to the transfer state. Included data depends on the state, e.g.: * * @remarks * - Rejection reasons are included when the `state` is `REJECTED` * - Reason and comment are included when `state` is `CANCELED` */ metadata?: { [k: string]: any } | null | undefined; /** * The high level state of a transfer, one of: * * @remarks * - `PROCESSING` - The transfer is being processed and will be posted if successful. * - `PENDING_REVIEW` - The transfer is pending review and will continue processing if approved. * - `POSTED` - The transfer has been posted to the ledger and will be completed at the end of the processing window if not canceled first. * - `COMPLETED` - The transfer has been batched and completed. * - `REJECTED` - The transfer was rejected. * - `CANCELED` - The transfer was canceled. * - `RETURNED` - The transfer was returned. * - `POSTPONED` - The transfer is postponed and will resume processing during the next processing window. */ state?: TransfersCreditStateStateOpen | undefined; /** * The time of the state update. */ updateTime?: Date | null | undefined; }; /** * The type of the credit being issued */ export enum TransfersCreditType { TypeUnspecified = "TYPE_UNSPECIFIED", Promotional = "PROMOTIONAL", WriteOff = "WRITE_OFF", Reimbursement = "REIMBURSEMENT", } /** * The type of the credit being issued */ export type TransfersCreditTypeOpen = OpenEnum; /** * A transfer using the CREDIT mechanism. Funds are moved from a firm account to a customer's brokerage account */ export type TransfersCredit = { /** * The amount of the credit being issued to the investor */ amount?: TransfersCreditAmount | null | undefined; /** * Bulk upload identifier to group related credit transfers */ bulkUploadId?: string | undefined; /** * External identifier supplied by the API caller. Each request must have a unique pairing of client_transfer_id and account */ clientTransferId?: string | undefined; /** * 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; /** * Full name of the credit resource, which contains account id and credit transaction id */ name?: string | undefined; /** * The current state of the credit */ state?: TransfersCreditState | null | undefined; /** * The type of the credit being issued */ type?: TransfersCreditTypeOpen | undefined; }; /** @internal */ export const TransfersCreditAmount$inboundSchema: z.ZodType< TransfersCreditAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type TransfersCreditAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const TransfersCreditAmount$outboundSchema: z.ZodType< TransfersCreditAmount$Outbound, z.ZodTypeDef, TransfersCreditAmount > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TransfersCreditAmount$ { /** @deprecated use `TransfersCreditAmount$inboundSchema` instead. */ export const inboundSchema = TransfersCreditAmount$inboundSchema; /** @deprecated use `TransfersCreditAmount$outboundSchema` instead. */ export const outboundSchema = TransfersCreditAmount$outboundSchema; /** @deprecated use `TransfersCreditAmount$Outbound` instead. */ export type Outbound = TransfersCreditAmount$Outbound; } export function transfersCreditAmountToJSON( transfersCreditAmount: TransfersCreditAmount, ): string { return JSON.stringify( TransfersCreditAmount$outboundSchema.parse(transfersCreditAmount), ); } export function transfersCreditAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersCreditAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersCreditAmount' from JSON`, ); } /** @internal */ export const TransfersCreditStateState$inboundSchema: z.ZodType< TransfersCreditStateStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TransfersCreditStateState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TransfersCreditStateState$outboundSchema: z.ZodType< TransfersCreditStateStateOpen, z.ZodTypeDef, TransfersCreditStateStateOpen > = z.union([ z.nativeEnum(TransfersCreditStateState), 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 TransfersCreditStateState$ { /** @deprecated use `TransfersCreditStateState$inboundSchema` instead. */ export const inboundSchema = TransfersCreditStateState$inboundSchema; /** @deprecated use `TransfersCreditStateState$outboundSchema` instead. */ export const outboundSchema = TransfersCreditStateState$outboundSchema; } /** @internal */ export const TransfersCreditState$inboundSchema: z.ZodType< TransfersCreditState, z.ZodTypeDef, unknown > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: TransfersCreditStateState$inboundSchema.optional(), update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "update_time": "updateTime", }); }); /** @internal */ export type TransfersCreditState$Outbound = { actor?: string | undefined; message?: string | undefined; metadata?: { [k: string]: any } | null | undefined; state?: string | undefined; update_time?: string | null | undefined; }; /** @internal */ export const TransfersCreditState$outboundSchema: z.ZodType< TransfersCreditState$Outbound, z.ZodTypeDef, TransfersCreditState > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: TransfersCreditStateState$outboundSchema.optional(), updateTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { updateTime: "update_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TransfersCreditState$ { /** @deprecated use `TransfersCreditState$inboundSchema` instead. */ export const inboundSchema = TransfersCreditState$inboundSchema; /** @deprecated use `TransfersCreditState$outboundSchema` instead. */ export const outboundSchema = TransfersCreditState$outboundSchema; /** @deprecated use `TransfersCreditState$Outbound` instead. */ export type Outbound = TransfersCreditState$Outbound; } export function transfersCreditStateToJSON( transfersCreditState: TransfersCreditState, ): string { return JSON.stringify( TransfersCreditState$outboundSchema.parse(transfersCreditState), ); } export function transfersCreditStateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersCreditState$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersCreditState' from JSON`, ); } /** @internal */ export const TransfersCreditType$inboundSchema: z.ZodType< TransfersCreditTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TransfersCreditType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TransfersCreditType$outboundSchema: z.ZodType< TransfersCreditTypeOpen, z.ZodTypeDef, TransfersCreditTypeOpen > = z.union([ z.nativeEnum(TransfersCreditType), 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 TransfersCreditType$ { /** @deprecated use `TransfersCreditType$inboundSchema` instead. */ export const inboundSchema = TransfersCreditType$inboundSchema; /** @deprecated use `TransfersCreditType$outboundSchema` instead. */ export const outboundSchema = TransfersCreditType$outboundSchema; } /** @internal */ export const TransfersCredit$inboundSchema: z.ZodType< TransfersCredit, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => TransfersCreditAmount$inboundSchema)) .optional(), bulk_upload_id: z.string().optional(), client_transfer_id: z.string().optional(), description: z.string().optional(), fee_operating_account: z.string().optional(), name: z.string().optional(), state: z.nullable(z.lazy(() => TransfersCreditState$inboundSchema)) .optional(), type: TransfersCreditType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "bulk_upload_id": "bulkUploadId", "client_transfer_id": "clientTransferId", "fee_operating_account": "feeOperatingAccount", }); }); /** @internal */ export type TransfersCredit$Outbound = { amount?: TransfersCreditAmount$Outbound | null | undefined; bulk_upload_id?: string | undefined; client_transfer_id?: string | undefined; description?: string | undefined; fee_operating_account?: string | undefined; name?: string | undefined; state?: TransfersCreditState$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const TransfersCredit$outboundSchema: z.ZodType< TransfersCredit$Outbound, z.ZodTypeDef, TransfersCredit > = z.object({ amount: z.nullable(z.lazy(() => TransfersCreditAmount$outboundSchema)) .optional(), bulkUploadId: z.string().optional(), clientTransferId: z.string().optional(), description: z.string().optional(), feeOperatingAccount: z.string().optional(), name: z.string().optional(), state: z.nullable(z.lazy(() => TransfersCreditState$outboundSchema)) .optional(), type: TransfersCreditType$outboundSchema.optional(), }).transform((v) => { return remap$(v, { bulkUploadId: "bulk_upload_id", 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 TransfersCredit$ { /** @deprecated use `TransfersCredit$inboundSchema` instead. */ export const inboundSchema = TransfersCredit$inboundSchema; /** @deprecated use `TransfersCredit$outboundSchema` instead. */ export const outboundSchema = TransfersCredit$outboundSchema; /** @deprecated use `TransfersCredit$Outbound` instead. */ export type Outbound = TransfersCredit$Outbound; } export function transfersCreditToJSON( transfersCredit: TransfersCredit, ): string { return JSON.stringify(TransfersCredit$outboundSchema.parse(transfersCredit)); } export function transfersCreditFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersCredit$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersCredit' from JSON`, ); }