/* * 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"; /** * The price value */ export type MarkPricePrice = { /** * 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; }; /** * The calculation type of this price */ export enum MarkPriceType { PercentageOfPar = "PERCENTAGE_OF_PAR", DirtyPercentageOfPar = "DIRTY_PERCENTAGE_OF_PAR", YieldToWorst = "YIELD_TO_WORST", YieldToMaturity = "YIELD_TO_MATURITY", } /** * The calculation type of this price */ export type MarkPriceTypeOpen = OpenEnum; /** * The definition of a price value and its calculation method as returned in mark data */ export type MarkPrice = { /** * The price value */ price?: MarkPricePrice | null | undefined; /** * The calculation type of this price */ type?: MarkPriceTypeOpen | undefined; }; /** @internal */ export const MarkPricePrice$inboundSchema: z.ZodType< MarkPricePrice, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type MarkPricePrice$Outbound = { value?: string | undefined; }; /** @internal */ export const MarkPricePrice$outboundSchema: z.ZodType< MarkPricePrice$Outbound, z.ZodTypeDef, MarkPricePrice > = 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 MarkPricePrice$ { /** @deprecated use `MarkPricePrice$inboundSchema` instead. */ export const inboundSchema = MarkPricePrice$inboundSchema; /** @deprecated use `MarkPricePrice$outboundSchema` instead. */ export const outboundSchema = MarkPricePrice$outboundSchema; /** @deprecated use `MarkPricePrice$Outbound` instead. */ export type Outbound = MarkPricePrice$Outbound; } export function markPricePriceToJSON(markPricePrice: MarkPricePrice): string { return JSON.stringify(MarkPricePrice$outboundSchema.parse(markPricePrice)); } export function markPricePriceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MarkPricePrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MarkPricePrice' from JSON`, ); } /** @internal */ export const MarkPriceType$inboundSchema: z.ZodType< MarkPriceTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(MarkPriceType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const MarkPriceType$outboundSchema: z.ZodType< MarkPriceTypeOpen, z.ZodTypeDef, MarkPriceTypeOpen > = z.union([ z.nativeEnum(MarkPriceType), 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 MarkPriceType$ { /** @deprecated use `MarkPriceType$inboundSchema` instead. */ export const inboundSchema = MarkPriceType$inboundSchema; /** @deprecated use `MarkPriceType$outboundSchema` instead. */ export const outboundSchema = MarkPriceType$outboundSchema; } /** @internal */ export const MarkPrice$inboundSchema: z.ZodType< MarkPrice, z.ZodTypeDef, unknown > = z.object({ price: z.nullable(z.lazy(() => MarkPricePrice$inboundSchema)).optional(), type: MarkPriceType$inboundSchema.optional(), }); /** @internal */ export type MarkPrice$Outbound = { price?: MarkPricePrice$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const MarkPrice$outboundSchema: z.ZodType< MarkPrice$Outbound, z.ZodTypeDef, MarkPrice > = z.object({ price: z.nullable(z.lazy(() => MarkPricePrice$outboundSchema)).optional(), type: MarkPriceType$outboundSchema.optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace MarkPrice$ { /** @deprecated use `MarkPrice$inboundSchema` instead. */ export const inboundSchema = MarkPrice$inboundSchema; /** @deprecated use `MarkPrice$outboundSchema` instead. */ export const outboundSchema = MarkPrice$outboundSchema; /** @deprecated use `MarkPrice$Outbound` instead. */ export type Outbound = MarkPrice$Outbound; } export function markPriceToJSON(markPrice: MarkPrice): string { return JSON.stringify(MarkPrice$outboundSchema.parse(markPrice)); } export function markPriceFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MarkPrice$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MarkPrice' from JSON`, ); }