/* * 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"; /** * Identifier type for the asset being moved */ export enum IdentifierType { IdentifierTypeUnspecified = "IDENTIFIER_TYPE_UNSPECIFIED", Cusip = "CUSIP", Symbol = "SYMBOL", AssetId = "ASSET_ID", } /** * Identifier type for the asset being moved */ export type IdentifierTypeOpen = OpenEnum; /** * The type of position journal */ export enum PositionJournalCreateType { TypeUnspecified = "TYPE_UNSPECIFIED", Reward = "REWARD", } /** * The type of position journal */ export type PositionJournalCreateTypeOpen = OpenEnum< typeof PositionJournalCreateType >; /** * A position journal transfer. Securities are moved from a source account to a destination account */ export type PositionJournalCreate = { /** * The external identifier supplied by the API caller Each request must have a unique pairing of `client_transfer_id` and `source_account` */ clientTransferId: string; /** * Optional description information that will attach to the transaction */ description?: string | undefined; /** * The account that securities will be moved to */ destinationAccount: string; /** * 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 */ fairMarketValue?: DecimalCreate | undefined; /** * Identifier (of the type specified in `identifier_type`). All identifiers are assumed to represent "US" issued securities. Responses will supply the originally requested identifier. */ identifier: string; /** * Identifier type for the asset being moved */ identifierType: IdentifierTypeOpen; /** * 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 */ quantity: DecimalCreate; /** * The account that securities will be moved from */ sourceAccount: string; /** * The type of position journal */ type: PositionJournalCreateTypeOpen; }; /** @internal */ export const IdentifierType$inboundSchema: z.ZodType< IdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(IdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const IdentifierType$outboundSchema: z.ZodType< IdentifierTypeOpen, z.ZodTypeDef, IdentifierTypeOpen > = z.union([ z.nativeEnum(IdentifierType), 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 IdentifierType$ { /** @deprecated use `IdentifierType$inboundSchema` instead. */ export const inboundSchema = IdentifierType$inboundSchema; /** @deprecated use `IdentifierType$outboundSchema` instead. */ export const outboundSchema = IdentifierType$outboundSchema; } /** @internal */ export const PositionJournalCreateType$inboundSchema: z.ZodType< PositionJournalCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(PositionJournalCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const PositionJournalCreateType$outboundSchema: z.ZodType< PositionJournalCreateTypeOpen, z.ZodTypeDef, PositionJournalCreateTypeOpen > = z.union([ z.nativeEnum(PositionJournalCreateType), 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 PositionJournalCreateType$ { /** @deprecated use `PositionJournalCreateType$inboundSchema` instead. */ export const inboundSchema = PositionJournalCreateType$inboundSchema; /** @deprecated use `PositionJournalCreateType$outboundSchema` instead. */ export const outboundSchema = PositionJournalCreateType$outboundSchema; } /** @internal */ export const PositionJournalCreate$inboundSchema: z.ZodType< PositionJournalCreate, z.ZodTypeDef, unknown > = z.object({ client_transfer_id: z.string(), description: z.string().optional(), destination_account: z.string(), fair_market_value: DecimalCreate$inboundSchema.optional(), identifier: z.string(), identifier_type: IdentifierType$inboundSchema, quantity: DecimalCreate$inboundSchema, source_account: z.string(), type: PositionJournalCreateType$inboundSchema, }).transform((v) => { return remap$(v, { "client_transfer_id": "clientTransferId", "destination_account": "destinationAccount", "fair_market_value": "fairMarketValue", "identifier_type": "identifierType", "source_account": "sourceAccount", }); }); /** @internal */ export type PositionJournalCreate$Outbound = { client_transfer_id: string; description?: string | undefined; destination_account: string; fair_market_value?: DecimalCreate$Outbound | undefined; identifier: string; identifier_type: string; quantity: DecimalCreate$Outbound; source_account: string; type: string; }; /** @internal */ export const PositionJournalCreate$outboundSchema: z.ZodType< PositionJournalCreate$Outbound, z.ZodTypeDef, PositionJournalCreate > = z.object({ clientTransferId: z.string(), description: z.string().optional(), destinationAccount: z.string(), fairMarketValue: DecimalCreate$outboundSchema.optional(), identifier: z.string(), identifierType: IdentifierType$outboundSchema, quantity: DecimalCreate$outboundSchema, sourceAccount: z.string(), type: PositionJournalCreateType$outboundSchema, }).transform((v) => { return remap$(v, { clientTransferId: "client_transfer_id", destinationAccount: "destination_account", fairMarketValue: "fair_market_value", identifierType: "identifier_type", 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 PositionJournalCreate$ { /** @deprecated use `PositionJournalCreate$inboundSchema` instead. */ export const inboundSchema = PositionJournalCreate$inboundSchema; /** @deprecated use `PositionJournalCreate$outboundSchema` instead. */ export const outboundSchema = PositionJournalCreate$outboundSchema; /** @deprecated use `PositionJournalCreate$Outbound` instead. */ export type Outbound = PositionJournalCreate$Outbound; } export function positionJournalCreateToJSON( positionJournalCreate: PositionJournalCreate, ): string { return JSON.stringify( PositionJournalCreate$outboundSchema.parse(positionJournalCreate), ); } export function positionJournalCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => PositionJournalCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'PositionJournalCreate' from JSON`, ); }