/* * 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"; /** * The percentage yield. */ export type Percent = { /** * 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 type of yield. */ export enum BondYieldYieldType { 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 BondYieldYieldTypeOpen = OpenEnum; /** * A percentage yield */ export type BondYield = { /** * The percentage yield. */ percent?: Percent | null | undefined; /** * The type of yield. */ yieldType?: BondYieldYieldTypeOpen | undefined; }; /** @internal */ export const Percent$inboundSchema: z.ZodType = z.object({ value: z.string().optional(), }); /** @internal */ export type Percent$Outbound = { value?: string | undefined; }; /** @internal */ export const Percent$outboundSchema: z.ZodType< Percent$Outbound, z.ZodTypeDef, Percent > = 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 Percent$ { /** @deprecated use `Percent$inboundSchema` instead. */ export const inboundSchema = Percent$inboundSchema; /** @deprecated use `Percent$outboundSchema` instead. */ export const outboundSchema = Percent$outboundSchema; /** @deprecated use `Percent$Outbound` instead. */ export type Outbound = Percent$Outbound; } export function percentToJSON(percent: Percent): string { return JSON.stringify(Percent$outboundSchema.parse(percent)); } export function percentFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Percent$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Percent' from JSON`, ); } /** @internal */ export const BondYieldYieldType$inboundSchema: z.ZodType< BondYieldYieldTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BondYieldYieldType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BondYieldYieldType$outboundSchema: z.ZodType< BondYieldYieldTypeOpen, z.ZodTypeDef, BondYieldYieldTypeOpen > = z.union([ z.nativeEnum(BondYieldYieldType), 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 BondYieldYieldType$ { /** @deprecated use `BondYieldYieldType$inboundSchema` instead. */ export const inboundSchema = BondYieldYieldType$inboundSchema; /** @deprecated use `BondYieldYieldType$outboundSchema` instead. */ export const outboundSchema = BondYieldYieldType$outboundSchema; } /** @internal */ export const BondYield$inboundSchema: z.ZodType< BondYield, z.ZodTypeDef, unknown > = z.object({ percent: z.nullable(z.lazy(() => Percent$inboundSchema)).optional(), yield_type: BondYieldYieldType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "yield_type": "yieldType", }); }); /** @internal */ export type BondYield$Outbound = { percent?: Percent$Outbound | null | undefined; yield_type?: string | undefined; }; /** @internal */ export const BondYield$outboundSchema: z.ZodType< BondYield$Outbound, z.ZodTypeDef, BondYield > = z.object({ percent: z.nullable(z.lazy(() => Percent$outboundSchema)).optional(), yieldType: BondYieldYieldType$outboundSchema.optional(), }).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 BondYield$ { /** @deprecated use `BondYield$inboundSchema` instead. */ export const inboundSchema = BondYield$inboundSchema; /** @deprecated use `BondYield$outboundSchema` instead. */ export const outboundSchema = BondYield$outboundSchema; /** @deprecated use `BondYield$Outbound` instead. */ export type Outbound = BondYield$Outbound; } export function bondYieldToJSON(bondYield: BondYield): string { return JSON.stringify(BondYield$outboundSchema.parse(bondYield)); } export function bondYieldFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BondYield$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BondYield' from JSON`, ); }