/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; 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"; /** * The type of this price, which must PRICE_PER_UNIT for equity orders. (Fixed income and mutual fund assets do not support stop orders.) */ export enum StopPriceCreateType { StopPriceTypeUnspecified = "STOP_PRICE_TYPE_UNSPECIFIED", PricePerUnit = "PRICE_PER_UNIT", } /** * The type of this price, which must PRICE_PER_UNIT for equity orders. (Fixed income and mutual fund assets do not support stop orders.) */ export type StopPriceCreateTypeOpen = OpenEnum; /** * A stop price definition */ export type StopPriceCreate = { /** * 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 */ price: DecimalCreate; /** * The type of this price, which must PRICE_PER_UNIT for equity orders. (Fixed income and mutual fund assets do not support stop orders.) */ type: StopPriceCreateTypeOpen; }; /** @internal */ export const StopPriceCreateType$inboundSchema: z.ZodType< StopPriceCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(StopPriceCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const StopPriceCreateType$outboundSchema: z.ZodType< StopPriceCreateTypeOpen, z.ZodTypeDef, StopPriceCreateTypeOpen > = z.union([ z.nativeEnum(StopPriceCreateType), 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 StopPriceCreateType$ { /** @deprecated use `StopPriceCreateType$inboundSchema` instead. */ export const inboundSchema = StopPriceCreateType$inboundSchema; /** @deprecated use `StopPriceCreateType$outboundSchema` instead. */ export const outboundSchema = StopPriceCreateType$outboundSchema; } /** @internal */ export const StopPriceCreate$inboundSchema: z.ZodType< StopPriceCreate, z.ZodTypeDef, unknown > = z.object({ price: DecimalCreate$inboundSchema, type: StopPriceCreateType$inboundSchema, }); /** @internal */ export type StopPriceCreate$Outbound = { price: DecimalCreate$Outbound; type: string; }; /** @internal */ export const StopPriceCreate$outboundSchema: z.ZodType< StopPriceCreate$Outbound, z.ZodTypeDef, StopPriceCreate > = z.object({ price: DecimalCreate$outboundSchema, type: StopPriceCreateType$outboundSchema, }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace StopPriceCreate$ { /** @deprecated use `StopPriceCreate$inboundSchema` instead. */ export const inboundSchema = StopPriceCreate$inboundSchema; /** @deprecated use `StopPriceCreate$outboundSchema` instead. */ export const outboundSchema = StopPriceCreate$outboundSchema; /** @deprecated use `StopPriceCreate$Outbound` instead. */ export type Outbound = StopPriceCreate$Outbound; } export function stopPriceCreateToJSON( stopPriceCreate: StopPriceCreate, ): string { return JSON.stringify(StopPriceCreate$outboundSchema.parse(stopPriceCreate)); } export function stopPriceCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => StopPriceCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'StopPriceCreate' from JSON`, ); }