/* * 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 fee being charged from the investor's account */ export type TransfersFeeAmount = { /** * 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 TransfersFeeStateState { 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 TransfersFeeStateStateOpen = OpenEnum< typeof TransfersFeeStateState >; /** * The current state of the fee */ export type TransfersFeeState = { /** * 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?: TransfersFeeStateStateOpen | undefined; /** * The time of the state update. */ updateTime?: Date | null | undefined; }; /** * The type of the fee being charged */ export enum TransfersFeeType { TypeUnspecified = "TYPE_UNSPECIFIED", Management = "MANAGEMENT", Advisory = "ADVISORY", Exchange = "EXCHANGE", Platform = "PLATFORM", Inactivity = "INACTIVITY", } /** * The type of the fee being charged */ export type TransfersFeeTypeOpen = OpenEnum; /** * A transfer using the FEE mechanism. Funds are moved from a customer's brokerage account to the firm account */ export type TransfersFee = { /** * The amount of the fee being charged from the investor's account */ amount?: TransfersFeeAmount | null | undefined; /** * Bulk upload identifier to group related fee 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 fee amount should be deposited into. 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 fee resource, which contains account id and fee transaction id */ name?: string | undefined; /** * The current state of the fee */ state?: TransfersFeeState | null | undefined; /** * The type of the fee being charged */ type?: TransfersFeeTypeOpen | undefined; }; /** @internal */ export const TransfersFeeAmount$inboundSchema: z.ZodType< TransfersFeeAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type TransfersFeeAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const TransfersFeeAmount$outboundSchema: z.ZodType< TransfersFeeAmount$Outbound, z.ZodTypeDef, TransfersFeeAmount > = 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 TransfersFeeAmount$ { /** @deprecated use `TransfersFeeAmount$inboundSchema` instead. */ export const inboundSchema = TransfersFeeAmount$inboundSchema; /** @deprecated use `TransfersFeeAmount$outboundSchema` instead. */ export const outboundSchema = TransfersFeeAmount$outboundSchema; /** @deprecated use `TransfersFeeAmount$Outbound` instead. */ export type Outbound = TransfersFeeAmount$Outbound; } export function transfersFeeAmountToJSON( transfersFeeAmount: TransfersFeeAmount, ): string { return JSON.stringify( TransfersFeeAmount$outboundSchema.parse(transfersFeeAmount), ); } export function transfersFeeAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersFeeAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersFeeAmount' from JSON`, ); } /** @internal */ export const TransfersFeeStateState$inboundSchema: z.ZodType< TransfersFeeStateStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TransfersFeeStateState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TransfersFeeStateState$outboundSchema: z.ZodType< TransfersFeeStateStateOpen, z.ZodTypeDef, TransfersFeeStateStateOpen > = z.union([ z.nativeEnum(TransfersFeeStateState), 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 TransfersFeeStateState$ { /** @deprecated use `TransfersFeeStateState$inboundSchema` instead. */ export const inboundSchema = TransfersFeeStateState$inboundSchema; /** @deprecated use `TransfersFeeStateState$outboundSchema` instead. */ export const outboundSchema = TransfersFeeStateState$outboundSchema; } /** @internal */ export const TransfersFeeState$inboundSchema: z.ZodType< TransfersFeeState, z.ZodTypeDef, unknown > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: TransfersFeeStateState$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 TransfersFeeState$Outbound = { actor?: string | undefined; message?: string | undefined; metadata?: { [k: string]: any } | null | undefined; state?: string | undefined; update_time?: string | null | undefined; }; /** @internal */ export const TransfersFeeState$outboundSchema: z.ZodType< TransfersFeeState$Outbound, z.ZodTypeDef, TransfersFeeState > = z.object({ actor: z.string().optional(), message: z.string().optional(), metadata: z.nullable(z.record(z.any())).optional(), state: TransfersFeeStateState$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 TransfersFeeState$ { /** @deprecated use `TransfersFeeState$inboundSchema` instead. */ export const inboundSchema = TransfersFeeState$inboundSchema; /** @deprecated use `TransfersFeeState$outboundSchema` instead. */ export const outboundSchema = TransfersFeeState$outboundSchema; /** @deprecated use `TransfersFeeState$Outbound` instead. */ export type Outbound = TransfersFeeState$Outbound; } export function transfersFeeStateToJSON( transfersFeeState: TransfersFeeState, ): string { return JSON.stringify( TransfersFeeState$outboundSchema.parse(transfersFeeState), ); } export function transfersFeeStateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersFeeState$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersFeeState' from JSON`, ); } /** @internal */ export const TransfersFeeType$inboundSchema: z.ZodType< TransfersFeeTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TransfersFeeType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TransfersFeeType$outboundSchema: z.ZodType< TransfersFeeTypeOpen, z.ZodTypeDef, TransfersFeeTypeOpen > = z.union([ z.nativeEnum(TransfersFeeType), 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 TransfersFeeType$ { /** @deprecated use `TransfersFeeType$inboundSchema` instead. */ export const inboundSchema = TransfersFeeType$inboundSchema; /** @deprecated use `TransfersFeeType$outboundSchema` instead. */ export const outboundSchema = TransfersFeeType$outboundSchema; } /** @internal */ export const TransfersFee$inboundSchema: z.ZodType< TransfersFee, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => TransfersFeeAmount$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(() => TransfersFeeState$inboundSchema)).optional(), type: TransfersFeeType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "bulk_upload_id": "bulkUploadId", "client_transfer_id": "clientTransferId", "fee_operating_account": "feeOperatingAccount", }); }); /** @internal */ export type TransfersFee$Outbound = { amount?: TransfersFeeAmount$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?: TransfersFeeState$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const TransfersFee$outboundSchema: z.ZodType< TransfersFee$Outbound, z.ZodTypeDef, TransfersFee > = z.object({ amount: z.nullable(z.lazy(() => TransfersFeeAmount$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(() => TransfersFeeState$outboundSchema)).optional(), type: TransfersFeeType$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 TransfersFee$ { /** @deprecated use `TransfersFee$inboundSchema` instead. */ export const inboundSchema = TransfersFee$inboundSchema; /** @deprecated use `TransfersFee$outboundSchema` instead. */ export const outboundSchema = TransfersFee$outboundSchema; /** @deprecated use `TransfersFee$Outbound` instead. */ export type Outbound = TransfersFee$Outbound; } export function transfersFeeToJSON(transfersFee: TransfersFee): string { return JSON.stringify(TransfersFee$outboundSchema.parse(transfersFee)); } export function transfersFeeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TransfersFee$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TransfersFee' from JSON`, ); }