/* * 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"; /** * Type to identify the option asset associated with the instruction */ export enum OptionInstructionIdentifierType { IdentifierTypeUnspecified = "IDENTIFIER_TYPE_UNSPECIFIED", AssetId = "ASSET_ID", Osi = "OSI", } /** * Type to identify the option asset associated with the instruction */ export type OptionInstructionIdentifierTypeOpen = OpenEnum< typeof OptionInstructionIdentifierType >; /** * Quantity for the instruction */ export type OptionInstructionQuantity = { /** * The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details */ value?: string | undefined; }; /** * Current state of the instruction */ export enum OptionInstructionState { StateUnspecified = "STATE_UNSPECIFIED", Pending = "PENDING", Rejected = "REJECTED", Accepted = "ACCEPTED", Canceled = "CANCELED", Completed = "COMPLETED", } /** * Current state of the instruction */ export type OptionInstructionStateOpen = OpenEnum< typeof OptionInstructionState >; /** * Type of instruction */ export enum OptionInstructionType { InstructionTypeUnspecified = "INSTRUCTION_TYPE_UNSPECIFIED", DoNotExercise = "DO_NOT_EXERCISE", ExerciseByException = "EXERCISE_BY_EXCEPTION", EarlyExercise = "EARLY_EXERCISE", } /** * Type of instruction */ export type OptionInstructionTypeOpen = OpenEnum; /** * Represents a single options trading instruction including do not exercise, exercise by exception, and early exercise instructions */ export type OptionInstruction = { /** * Account identifier */ accountId?: string | undefined; /** * The time the instruction was created */ createTime?: Date | null | undefined; /** * The asset identifier */ identifier?: string | undefined; /** * Type to identify the option asset associated with the instruction */ identifierType?: OptionInstructionIdentifierTypeOpen | undefined; /** * Instruction identifier which is unique and provided by the server */ instructionId?: string | undefined; /** * The name of the instruction (e.g., "accounts/{account}/assets/{asset}/instructions/{instruction_id}"). */ name?: string | undefined; /** * Quantity for the instruction */ quantity?: OptionInstructionQuantity | null | undefined; /** * Current state of the instruction */ state?: OptionInstructionStateOpen | undefined; /** * State description relating to the state */ stateDescription?: string | undefined; /** * Type of instruction */ type?: OptionInstructionTypeOpen | undefined; /** * The time the instruction was updated */ updateTime?: Date | null | undefined; }; /** @internal */ export const OptionInstructionIdentifierType$inboundSchema: z.ZodType< OptionInstructionIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionInstructionIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionInstructionIdentifierType$outboundSchema: z.ZodType< OptionInstructionIdentifierTypeOpen, z.ZodTypeDef, OptionInstructionIdentifierTypeOpen > = z.union([ z.nativeEnum(OptionInstructionIdentifierType), 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 OptionInstructionIdentifierType$ { /** @deprecated use `OptionInstructionIdentifierType$inboundSchema` instead. */ export const inboundSchema = OptionInstructionIdentifierType$inboundSchema; /** @deprecated use `OptionInstructionIdentifierType$outboundSchema` instead. */ export const outboundSchema = OptionInstructionIdentifierType$outboundSchema; } /** @internal */ export const OptionInstructionQuantity$inboundSchema: z.ZodType< OptionInstructionQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type OptionInstructionQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const OptionInstructionQuantity$outboundSchema: z.ZodType< OptionInstructionQuantity$Outbound, z.ZodTypeDef, OptionInstructionQuantity > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionInstructionQuantity$ { /** @deprecated use `OptionInstructionQuantity$inboundSchema` instead. */ export const inboundSchema = OptionInstructionQuantity$inboundSchema; /** @deprecated use `OptionInstructionQuantity$outboundSchema` instead. */ export const outboundSchema = OptionInstructionQuantity$outboundSchema; /** @deprecated use `OptionInstructionQuantity$Outbound` instead. */ export type Outbound = OptionInstructionQuantity$Outbound; } export function optionInstructionQuantityToJSON( optionInstructionQuantity: OptionInstructionQuantity, ): string { return JSON.stringify( OptionInstructionQuantity$outboundSchema.parse(optionInstructionQuantity), ); } export function optionInstructionQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionInstructionQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionInstructionQuantity' from JSON`, ); } /** @internal */ export const OptionInstructionState$inboundSchema: z.ZodType< OptionInstructionStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionInstructionState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionInstructionState$outboundSchema: z.ZodType< OptionInstructionStateOpen, z.ZodTypeDef, OptionInstructionStateOpen > = z.union([ z.nativeEnum(OptionInstructionState), 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 OptionInstructionState$ { /** @deprecated use `OptionInstructionState$inboundSchema` instead. */ export const inboundSchema = OptionInstructionState$inboundSchema; /** @deprecated use `OptionInstructionState$outboundSchema` instead. */ export const outboundSchema = OptionInstructionState$outboundSchema; } /** @internal */ export const OptionInstructionType$inboundSchema: z.ZodType< OptionInstructionTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(OptionInstructionType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const OptionInstructionType$outboundSchema: z.ZodType< OptionInstructionTypeOpen, z.ZodTypeDef, OptionInstructionTypeOpen > = z.union([ z.nativeEnum(OptionInstructionType), 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 OptionInstructionType$ { /** @deprecated use `OptionInstructionType$inboundSchema` instead. */ export const inboundSchema = OptionInstructionType$inboundSchema; /** @deprecated use `OptionInstructionType$outboundSchema` instead. */ export const outboundSchema = OptionInstructionType$outboundSchema; } /** @internal */ export const OptionInstruction$inboundSchema: z.ZodType< OptionInstruction, z.ZodTypeDef, unknown > = z.object({ account_id: z.string().optional(), create_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), identifier: z.string().optional(), identifier_type: OptionInstructionIdentifierType$inboundSchema.optional(), instruction_id: z.string().optional(), name: z.string().optional(), quantity: z.nullable(z.lazy(() => OptionInstructionQuantity$inboundSchema)) .optional(), state: OptionInstructionState$inboundSchema.optional(), state_description: z.string().optional(), type: OptionInstructionType$inboundSchema.optional(), update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "account_id": "accountId", "create_time": "createTime", "identifier_type": "identifierType", "instruction_id": "instructionId", "state_description": "stateDescription", "update_time": "updateTime", }); }); /** @internal */ export type OptionInstruction$Outbound = { account_id?: string | undefined; create_time?: string | null | undefined; identifier?: string | undefined; identifier_type?: string | undefined; instruction_id?: string | undefined; name?: string | undefined; quantity?: OptionInstructionQuantity$Outbound | null | undefined; state?: string | undefined; state_description?: string | undefined; type?: string | undefined; update_time?: string | null | undefined; }; /** @internal */ export const OptionInstruction$outboundSchema: z.ZodType< OptionInstruction$Outbound, z.ZodTypeDef, OptionInstruction > = z.object({ accountId: z.string().optional(), createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), identifier: z.string().optional(), identifierType: OptionInstructionIdentifierType$outboundSchema.optional(), instructionId: z.string().optional(), name: z.string().optional(), quantity: z.nullable(z.lazy(() => OptionInstructionQuantity$outboundSchema)) .optional(), state: OptionInstructionState$outboundSchema.optional(), stateDescription: z.string().optional(), type: OptionInstructionType$outboundSchema.optional(), updateTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { accountId: "account_id", createTime: "create_time", identifierType: "identifier_type", instructionId: "instruction_id", stateDescription: "state_description", updateTime: "update_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace OptionInstruction$ { /** @deprecated use `OptionInstruction$inboundSchema` instead. */ export const inboundSchema = OptionInstruction$inboundSchema; /** @deprecated use `OptionInstruction$outboundSchema` instead. */ export const outboundSchema = OptionInstruction$outboundSchema; /** @deprecated use `OptionInstruction$Outbound` instead. */ export type Outbound = OptionInstruction$Outbound; } export function optionInstructionToJSON( optionInstruction: OptionInstruction, ): string { return JSON.stringify( OptionInstruction$outboundSchema.parse(optionInstruction), ); } export function optionInstructionFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => OptionInstruction$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'OptionInstruction' from JSON`, ); }