/* * 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"; /** * Identifies the distribution type for buy side orders (that is, when `side` value = `BUY`). - Orders will be rejected if the alternative investment asset does not allow the requested distribution type. - Not relevant for sell orders (that is, when `side` value = `SELL`). - Confirm the asset’s `cash_distribution_allowed` and `reinvestment_distribution_allowed` properties to know what it allows. */ export enum DistributionType { DistributionTypeUnspecified = "DISTRIBUTION_TYPE_UNSPECIFIED", Cash = "CASH", Reinvestment = "REINVESTMENT", } /** * Identifies the distribution type for buy side orders (that is, when `side` value = `BUY`). - Orders will be rejected if the alternative investment asset does not allow the requested distribution type. - Not relevant for sell orders (that is, when `side` value = `SELL`). - Confirm the asset’s `cash_distribution_allowed` and `reinvestment_distribution_allowed` properties to know what it allows. */ export type DistributionTypeOpen = OpenEnum; /** * Identifies which parameter value is used to identify the asset in the order. The value for that parameter is used in the `identifier` field. */ export enum AlternativeOrderCreateIdentifierType { IdentifierTypeUnspecified = "IDENTIFIER_TYPE_UNSPECIFIED", AssetId = "ASSET_ID", } /** * Identifies which parameter value is used to identify the asset in the order. The value for that parameter is used in the `identifier` field. */ export type AlternativeOrderCreateIdentifierTypeOpen = OpenEnum< typeof AlternativeOrderCreateIdentifierType >; /** * The side of the order. */ export enum AlternativeOrderCreateSide { SideUnspecified = "SIDE_UNSPECIFIED", Buy = "BUY", Sell = "SELL", } /** * The side of the order. */ export type AlternativeOrderCreateSideOpen = OpenEnum< typeof AlternativeOrderCreateSide >; /** * An order for an alternative investment. */ export type AlternativeOrderCreate = { /** * A client-supplied unique ID to enforce idempotency. Each ID must be unique within the account. * * @remarks * * If a create request includes a `client_order_id` that matches an existing order’s `client_order_id`, the service will respond with `ALREADY_EXISTS` and will not create a new order resource. */ clientOrderId: string; /** * The currency code of the order. Supports only "USD" and will default to "USD" if unspecified in the request. */ currencyCode?: string | undefined; /** * Identifies the distribution type for buy side orders (that is, when `side` value = `BUY`). - Orders will be rejected if the alternative investment asset does not allow the requested distribution type. - Not relevant for sell orders (that is, when `side` value = `SELL`). - Confirm the asset’s `cash_distribution_allowed` and `reinvestment_distribution_allowed` properties to know what it allows. */ distributionType?: DistributionTypeOpen | undefined; /** * Indicates whether this order is for a full redemption (as in, all shares redeemed). - Orders can specify only one of `full`, `notional_value`, or `quantity`. - Note that the issuer may allow only partial redemption. - Not relevant to subscription orders. */ full?: boolean | undefined; /** * The asset identifier value, dependent on enum value set for `identifier_type`. * * @remarks * * For example, if `identifier_type` = `ASSET_ID`, then the value for `identifier` is the `asset_id` value. */ identifier: string; /** * Identifies which parameter value is used to identify the asset in the order. The value for that parameter is used in the `identifier` field. */ identifierType: AlternativeOrderCreateIdentifierTypeOpen; /** * 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 */ notionalValue?: DecimalCreate | undefined; /** * 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 | undefined; /** * The side of the order. */ side: AlternativeOrderCreateSideOpen; }; /** @internal */ export const DistributionType$inboundSchema: z.ZodType< DistributionTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(DistributionType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const DistributionType$outboundSchema: z.ZodType< DistributionTypeOpen, z.ZodTypeDef, DistributionTypeOpen > = z.union([ z.nativeEnum(DistributionType), 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 DistributionType$ { /** @deprecated use `DistributionType$inboundSchema` instead. */ export const inboundSchema = DistributionType$inboundSchema; /** @deprecated use `DistributionType$outboundSchema` instead. */ export const outboundSchema = DistributionType$outboundSchema; } /** @internal */ export const AlternativeOrderCreateIdentifierType$inboundSchema: z.ZodType< AlternativeOrderCreateIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AlternativeOrderCreateIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AlternativeOrderCreateIdentifierType$outboundSchema: z.ZodType< AlternativeOrderCreateIdentifierTypeOpen, z.ZodTypeDef, AlternativeOrderCreateIdentifierTypeOpen > = z.union([ z.nativeEnum(AlternativeOrderCreateIdentifierType), 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 AlternativeOrderCreateIdentifierType$ { /** @deprecated use `AlternativeOrderCreateIdentifierType$inboundSchema` instead. */ export const inboundSchema = AlternativeOrderCreateIdentifierType$inboundSchema; /** @deprecated use `AlternativeOrderCreateIdentifierType$outboundSchema` instead. */ export const outboundSchema = AlternativeOrderCreateIdentifierType$outboundSchema; } /** @internal */ export const AlternativeOrderCreateSide$inboundSchema: z.ZodType< AlternativeOrderCreateSideOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(AlternativeOrderCreateSide), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const AlternativeOrderCreateSide$outboundSchema: z.ZodType< AlternativeOrderCreateSideOpen, z.ZodTypeDef, AlternativeOrderCreateSideOpen > = z.union([ z.nativeEnum(AlternativeOrderCreateSide), 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 AlternativeOrderCreateSide$ { /** @deprecated use `AlternativeOrderCreateSide$inboundSchema` instead. */ export const inboundSchema = AlternativeOrderCreateSide$inboundSchema; /** @deprecated use `AlternativeOrderCreateSide$outboundSchema` instead. */ export const outboundSchema = AlternativeOrderCreateSide$outboundSchema; } /** @internal */ export const AlternativeOrderCreate$inboundSchema: z.ZodType< AlternativeOrderCreate, z.ZodTypeDef, unknown > = z.object({ client_order_id: z.string(), currency_code: z.string().optional(), distribution_type: DistributionType$inboundSchema.optional(), full: z.boolean().optional(), identifier: z.string(), identifier_type: AlternativeOrderCreateIdentifierType$inboundSchema, notional_value: DecimalCreate$inboundSchema.optional(), quantity: DecimalCreate$inboundSchema.optional(), side: AlternativeOrderCreateSide$inboundSchema, }).transform((v) => { return remap$(v, { "client_order_id": "clientOrderId", "currency_code": "currencyCode", "distribution_type": "distributionType", "identifier_type": "identifierType", "notional_value": "notionalValue", }); }); /** @internal */ export type AlternativeOrderCreate$Outbound = { client_order_id: string; currency_code?: string | undefined; distribution_type?: string | undefined; full?: boolean | undefined; identifier: string; identifier_type: string; notional_value?: DecimalCreate$Outbound | undefined; quantity?: DecimalCreate$Outbound | undefined; side: string; }; /** @internal */ export const AlternativeOrderCreate$outboundSchema: z.ZodType< AlternativeOrderCreate$Outbound, z.ZodTypeDef, AlternativeOrderCreate > = z.object({ clientOrderId: z.string(), currencyCode: z.string().optional(), distributionType: DistributionType$outboundSchema.optional(), full: z.boolean().optional(), identifier: z.string(), identifierType: AlternativeOrderCreateIdentifierType$outboundSchema, notionalValue: DecimalCreate$outboundSchema.optional(), quantity: DecimalCreate$outboundSchema.optional(), side: AlternativeOrderCreateSide$outboundSchema, }).transform((v) => { return remap$(v, { clientOrderId: "client_order_id", currencyCode: "currency_code", distributionType: "distribution_type", identifierType: "identifier_type", notionalValue: "notional_value", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AlternativeOrderCreate$ { /** @deprecated use `AlternativeOrderCreate$inboundSchema` instead. */ export const inboundSchema = AlternativeOrderCreate$inboundSchema; /** @deprecated use `AlternativeOrderCreate$outboundSchema` instead. */ export const outboundSchema = AlternativeOrderCreate$outboundSchema; /** @deprecated use `AlternativeOrderCreate$Outbound` instead. */ export type Outbound = AlternativeOrderCreate$Outbound; } export function alternativeOrderCreateToJSON( alternativeOrderCreate: AlternativeOrderCreate, ): string { return JSON.stringify( AlternativeOrderCreate$outboundSchema.parse(alternativeOrderCreate), ); } export function alternativeOrderCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AlternativeOrderCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AlternativeOrderCreate' from JSON`, ); }