/* * 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"; import { LimitPriceCreate, LimitPriceCreate$inboundSchema, LimitPriceCreate$Outbound, LimitPriceCreate$outboundSchema, } from "./limitpricecreate.js"; /** * The type of asset being evaluated in cost calculations. */ export enum OrderCostPreviewRequestCreateAssetType { FixedIncome = "FIXED_INCOME", } /** * The type of asset being evaluated in cost calculations. */ export type OrderCostPreviewRequestCreateAssetTypeOpen = OpenEnum< typeof OrderCostPreviewRequestCreateAssetType >; /** * Capacity used in determining the order cost. Defaults to "AGENCY" if no value specified. */ export enum OrderCostPreviewRequestCreateBrokerCapacity { BrokerCapacityUnspecified = "BROKER_CAPACITY_UNSPECIFIED", Agency = "AGENCY", Principal = "PRINCIPAL", } /** * Capacity used in determining the order cost. Defaults to "AGENCY" if no value specified. */ export type OrderCostPreviewRequestCreateBrokerCapacityOpen = OpenEnum< typeof OrderCostPreviewRequestCreateBrokerCapacity >; /** * The identifier type of the asset being sought */ export enum OrderCostPreviewRequestCreateIdentifierType { AssetId = "ASSET_ID", Cusip = "CUSIP", Isin = "ISIN", } /** * The identifier type of the asset being sought */ export type OrderCostPreviewRequestCreateIdentifierTypeOpen = OpenEnum< typeof OrderCostPreviewRequestCreateIdentifierType >; /** * Request object for retrieving fixed income costs */ export type OrderCostPreviewRequestCreate = { /** * The type of asset being evaluated in cost calculations. */ assetType: OrderCostPreviewRequestCreateAssetTypeOpen; /** * Capacity used in determining the order cost. Defaults to "AGENCY" if no value specified. */ brokerCapacity?: OrderCostPreviewRequestCreateBrokerCapacityOpen | undefined; /** * Identifier of the asset (of the type specified in `identifier_type`). */ identifier: string; /** * The identifier type of the asset being sought */ identifierType: OrderCostPreviewRequestCreateIdentifierTypeOpen; /** * A limit price definition */ limitPrice: LimitPriceCreate; /** * The parent resource where this order will be created. Format: accounts/{account_id} */ parent: 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 */ quantity: DecimalCreate; }; /** @internal */ export const OrderCostPreviewRequestCreateAssetType$inboundSchema: z.ZodType< OrderCostPreviewRequestCreateAssetTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OrderCostPreviewRequestCreateAssetType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OrderCostPreviewRequestCreateAssetType$outboundSchema: z.ZodType< OrderCostPreviewRequestCreateAssetTypeOpen, z.ZodTypeDef, OrderCostPreviewRequestCreateAssetTypeOpen > = z.union([ z.nativeEnum(OrderCostPreviewRequestCreateAssetType), 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 OrderCostPreviewRequestCreateAssetType$ { /** @deprecated use `OrderCostPreviewRequestCreateAssetType$inboundSchema` instead. */ export const inboundSchema = OrderCostPreviewRequestCreateAssetType$inboundSchema; /** @deprecated use `OrderCostPreviewRequestCreateAssetType$outboundSchema` instead. */ export const outboundSchema = OrderCostPreviewRequestCreateAssetType$outboundSchema; } /** @internal */ export const OrderCostPreviewRequestCreateBrokerCapacity$inboundSchema: z.ZodType< OrderCostPreviewRequestCreateBrokerCapacityOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OrderCostPreviewRequestCreateBrokerCapacity), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OrderCostPreviewRequestCreateBrokerCapacity$outboundSchema: z.ZodType< OrderCostPreviewRequestCreateBrokerCapacityOpen, z.ZodTypeDef, OrderCostPreviewRequestCreateBrokerCapacityOpen > = z.union([ z.nativeEnum(OrderCostPreviewRequestCreateBrokerCapacity), 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 OrderCostPreviewRequestCreateBrokerCapacity$ { /** @deprecated use `OrderCostPreviewRequestCreateBrokerCapacity$inboundSchema` instead. */ export const inboundSchema = OrderCostPreviewRequestCreateBrokerCapacity$inboundSchema; /** @deprecated use `OrderCostPreviewRequestCreateBrokerCapacity$outboundSchema` instead. */ export const outboundSchema = OrderCostPreviewRequestCreateBrokerCapacity$outboundSchema; } /** @internal */ export const OrderCostPreviewRequestCreateIdentifierType$inboundSchema: z.ZodType< OrderCostPreviewRequestCreateIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OrderCostPreviewRequestCreateIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OrderCostPreviewRequestCreateIdentifierType$outboundSchema: z.ZodType< OrderCostPreviewRequestCreateIdentifierTypeOpen, z.ZodTypeDef, OrderCostPreviewRequestCreateIdentifierTypeOpen > = z.union([ z.nativeEnum(OrderCostPreviewRequestCreateIdentifierType), 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 OrderCostPreviewRequestCreateIdentifierType$ { /** @deprecated use `OrderCostPreviewRequestCreateIdentifierType$inboundSchema` instead. */ export const inboundSchema = OrderCostPreviewRequestCreateIdentifierType$inboundSchema; /** @deprecated use `OrderCostPreviewRequestCreateIdentifierType$outboundSchema` instead. */ export const outboundSchema = OrderCostPreviewRequestCreateIdentifierType$outboundSchema; } /** @internal */ export const OrderCostPreviewRequestCreate$inboundSchema: z.ZodType< OrderCostPreviewRequestCreate, z.ZodTypeDef, unknown > = z.object({ asset_type: OrderCostPreviewRequestCreateAssetType$inboundSchema, broker_capacity: OrderCostPreviewRequestCreateBrokerCapacity$inboundSchema .optional(), identifier: z.string(), identifier_type: OrderCostPreviewRequestCreateIdentifierType$inboundSchema, limit_price: LimitPriceCreate$inboundSchema, parent: z.string(), quantity: DecimalCreate$inboundSchema, }).transform((v) => { return remap$(v, { "asset_type": "assetType", "broker_capacity": "brokerCapacity", "identifier_type": "identifierType", "limit_price": "limitPrice", }); }); /** @internal */ export type OrderCostPreviewRequestCreate$Outbound = { asset_type: string; broker_capacity?: string | undefined; identifier: string; identifier_type: string; limit_price: LimitPriceCreate$Outbound; parent: string; quantity: DecimalCreate$Outbound; }; /** @internal */ export const OrderCostPreviewRequestCreate$outboundSchema: z.ZodType< OrderCostPreviewRequestCreate$Outbound, z.ZodTypeDef, OrderCostPreviewRequestCreate > = z.object({ assetType: OrderCostPreviewRequestCreateAssetType$outboundSchema, brokerCapacity: OrderCostPreviewRequestCreateBrokerCapacity$outboundSchema .optional(), identifier: z.string(), identifierType: OrderCostPreviewRequestCreateIdentifierType$outboundSchema, limitPrice: LimitPriceCreate$outboundSchema, parent: z.string(), quantity: DecimalCreate$outboundSchema, }).transform((v) => { return remap$(v, { assetType: "asset_type", brokerCapacity: "broker_capacity", identifierType: "identifier_type", limitPrice: "limit_price", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OrderCostPreviewRequestCreate$ { /** @deprecated use `OrderCostPreviewRequestCreate$inboundSchema` instead. */ export const inboundSchema = OrderCostPreviewRequestCreate$inboundSchema; /** @deprecated use `OrderCostPreviewRequestCreate$outboundSchema` instead. */ export const outboundSchema = OrderCostPreviewRequestCreate$outboundSchema; /** @deprecated use `OrderCostPreviewRequestCreate$Outbound` instead. */ export type Outbound = OrderCostPreviewRequestCreate$Outbound; } export function orderCostPreviewRequestCreateToJSON( orderCostPreviewRequestCreate: OrderCostPreviewRequestCreate, ): string { return JSON.stringify( OrderCostPreviewRequestCreate$outboundSchema.parse( orderCostPreviewRequestCreate, ), ); } export function orderCostPreviewRequestCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OrderCostPreviewRequestCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OrderCostPreviewRequestCreate' from JSON`, ); }