/* * 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"; /** * Type to identify the option asset associated with the instruction */ export enum OptionInstructionCreateIdentifierType { IdentifierTypeUnspecified = "IDENTIFIER_TYPE_UNSPECIFIED", AssetId = "ASSET_ID", Osi = "OSI", } /** * Type to identify the option asset associated with the instruction */ export type OptionInstructionCreateIdentifierTypeOpen = OpenEnum< typeof OptionInstructionCreateIdentifierType >; /** * Type of instruction */ export enum OptionInstructionCreateType { InstructionTypeUnspecified = "INSTRUCTION_TYPE_UNSPECIFIED", DoNotExercise = "DO_NOT_EXERCISE", ExerciseByException = "EXERCISE_BY_EXCEPTION", EarlyExercise = "EARLY_EXERCISE", } /** * Type of instruction */ export type OptionInstructionCreateTypeOpen = OpenEnum< typeof OptionInstructionCreateType >; /** * Represents a single options trading instruction including do not exercise, exercise by exception, and early exercise instructions */ export type OptionInstructionCreate = { /** * Account identifier */ accountId: string; /** * The asset identifier */ identifier: string; /** * Type to identify the option asset associated with the instruction */ identifierType: OptionInstructionCreateIdentifierTypeOpen; /** * 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; /** * Type of instruction */ type: OptionInstructionCreateTypeOpen; }; /** @internal */ export const OptionInstructionCreateIdentifierType$inboundSchema: z.ZodType< OptionInstructionCreateIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionInstructionCreateIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionInstructionCreateIdentifierType$outboundSchema: z.ZodType< OptionInstructionCreateIdentifierTypeOpen, z.ZodTypeDef, OptionInstructionCreateIdentifierTypeOpen > = z.union([ z.nativeEnum(OptionInstructionCreateIdentifierType), 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 OptionInstructionCreateIdentifierType$ { /** @deprecated use `OptionInstructionCreateIdentifierType$inboundSchema` instead. */ export const inboundSchema = OptionInstructionCreateIdentifierType$inboundSchema; /** @deprecated use `OptionInstructionCreateIdentifierType$outboundSchema` instead. */ export const outboundSchema = OptionInstructionCreateIdentifierType$outboundSchema; } /** @internal */ export const OptionInstructionCreateType$inboundSchema: z.ZodType< OptionInstructionCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionInstructionCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionInstructionCreateType$outboundSchema: z.ZodType< OptionInstructionCreateTypeOpen, z.ZodTypeDef, OptionInstructionCreateTypeOpen > = z.union([ z.nativeEnum(OptionInstructionCreateType), 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 OptionInstructionCreateType$ { /** @deprecated use `OptionInstructionCreateType$inboundSchema` instead. */ export const inboundSchema = OptionInstructionCreateType$inboundSchema; /** @deprecated use `OptionInstructionCreateType$outboundSchema` instead. */ export const outboundSchema = OptionInstructionCreateType$outboundSchema; } /** @internal */ export const OptionInstructionCreate$inboundSchema: z.ZodType< OptionInstructionCreate, z.ZodTypeDef, unknown > = z.object({ account_id: z.string(), identifier: z.string(), identifier_type: OptionInstructionCreateIdentifierType$inboundSchema, quantity: DecimalCreate$inboundSchema, type: OptionInstructionCreateType$inboundSchema, }).transform((v) => { return remap$(v, { "account_id": "accountId", "identifier_type": "identifierType", }); }); /** @internal */ export type OptionInstructionCreate$Outbound = { account_id: string; identifier: string; identifier_type: string; quantity: DecimalCreate$Outbound; type: string; }; /** @internal */ export const OptionInstructionCreate$outboundSchema: z.ZodType< OptionInstructionCreate$Outbound, z.ZodTypeDef, OptionInstructionCreate > = z.object({ accountId: z.string(), identifier: z.string(), identifierType: OptionInstructionCreateIdentifierType$outboundSchema, quantity: DecimalCreate$outboundSchema, type: OptionInstructionCreateType$outboundSchema, }).transform((v) => { return remap$(v, { accountId: "account_id", identifierType: "identifier_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionInstructionCreate$ { /** @deprecated use `OptionInstructionCreate$inboundSchema` instead. */ export const inboundSchema = OptionInstructionCreate$inboundSchema; /** @deprecated use `OptionInstructionCreate$outboundSchema` instead. */ export const outboundSchema = OptionInstructionCreate$outboundSchema; /** @deprecated use `OptionInstructionCreate$Outbound` instead. */ export type Outbound = OptionInstructionCreate$Outbound; } export function optionInstructionCreateToJSON( optionInstructionCreate: OptionInstructionCreate, ): string { return JSON.stringify( OptionInstructionCreate$outboundSchema.parse(optionInstructionCreate), ); } export function optionInstructionCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionInstructionCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionInstructionCreate' from JSON`, ); }