/* * 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"; /** * The type of yield. */ export enum YieldType { YieldTypeUnspecified = "YIELD_TYPE_UNSPECIFIED", YieldToCall = "YIELD_TO_CALL", YieldToMaturity = "YIELD_TO_MATURITY", YieldToPut = "YIELD_TO_PUT", YieldToWorst = "YIELD_TO_WORST", } /** * The type of yield. */ export type YieldTypeOpen = OpenEnum; /** * A percentage yield */ export type BondYieldCreate = { /** * 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 */ percent: DecimalCreate; /** * The type of yield. */ yieldType: YieldTypeOpen; }; /** @internal */ export const YieldType$inboundSchema: z.ZodType< YieldTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(YieldType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const YieldType$outboundSchema: z.ZodType< YieldTypeOpen, z.ZodTypeDef, YieldTypeOpen > = z.union([ z.nativeEnum(YieldType), 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 YieldType$ { /** @deprecated use `YieldType$inboundSchema` instead. */ export const inboundSchema = YieldType$inboundSchema; /** @deprecated use `YieldType$outboundSchema` instead. */ export const outboundSchema = YieldType$outboundSchema; } /** @internal */ export const BondYieldCreate$inboundSchema: z.ZodType< BondYieldCreate, z.ZodTypeDef, unknown > = z.object({ percent: DecimalCreate$inboundSchema, yield_type: YieldType$inboundSchema, }).transform((v) => { return remap$(v, { "yield_type": "yieldType", }); }); /** @internal */ export type BondYieldCreate$Outbound = { percent: DecimalCreate$Outbound; yield_type: string; }; /** @internal */ export const BondYieldCreate$outboundSchema: z.ZodType< BondYieldCreate$Outbound, z.ZodTypeDef, BondYieldCreate > = z.object({ percent: DecimalCreate$outboundSchema, yieldType: YieldType$outboundSchema, }).transform((v) => { return remap$(v, { yieldType: "yield_type", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BondYieldCreate$ { /** @deprecated use `BondYieldCreate$inboundSchema` instead. */ export const inboundSchema = BondYieldCreate$inboundSchema; /** @deprecated use `BondYieldCreate$outboundSchema` instead. */ export const outboundSchema = BondYieldCreate$outboundSchema; /** @deprecated use `BondYieldCreate$Outbound` instead. */ export type Outbound = BondYieldCreate$Outbound; } export function bondYieldCreateToJSON( bondYieldCreate: BondYieldCreate, ): string { return JSON.stringify(BondYieldCreate$outboundSchema.parse(bondYieldCreate)); } export function bondYieldCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BondYieldCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BondYieldCreate' from JSON`, ); }