/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type ForecastTick = { date: Date; targetDateContract: string; closePrice: number; lowerBounds?: Array | null | undefined; upperBounds?: Array | null | undefined; sigmas?: Array | null | undefined; interpolated?: boolean | null | undefined; }; /** @internal */ export const ForecastTick$inboundSchema: z.ZodType< ForecastTick, z.ZodTypeDef, unknown > = z.object({ date: z.string().datetime({ offset: true }).transform(v => new Date(v)), target_date_contract: z.string(), close_price: z.number(), lower_bounds: z.nullable(z.array(z.number())).optional(), upper_bounds: z.nullable(z.array(z.number())).optional(), sigmas: z.nullable(z.array(z.number())).optional(), interpolated: z.nullable(z.boolean()).optional(), }).transform((v) => { return remap$(v, { "target_date_contract": "targetDateContract", "close_price": "closePrice", "lower_bounds": "lowerBounds", "upper_bounds": "upperBounds", }); }); /** @internal */ export type ForecastTick$Outbound = { date: string; target_date_contract: string; close_price: number; lower_bounds?: Array | null | undefined; upper_bounds?: Array | null | undefined; sigmas?: Array | null | undefined; interpolated?: boolean | null | undefined; }; /** @internal */ export const ForecastTick$outboundSchema: z.ZodType< ForecastTick$Outbound, z.ZodTypeDef, ForecastTick > = z.object({ date: z.date().transform(v => v.toISOString()), targetDateContract: z.string(), closePrice: z.number(), lowerBounds: z.nullable(z.array(z.number())).optional(), upperBounds: z.nullable(z.array(z.number())).optional(), sigmas: z.nullable(z.array(z.number())).optional(), interpolated: z.nullable(z.boolean()).optional(), }).transform((v) => { return remap$(v, { targetDateContract: "target_date_contract", closePrice: "close_price", lowerBounds: "lower_bounds", upperBounds: "upper_bounds", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace ForecastTick$ { /** @deprecated use `ForecastTick$inboundSchema` instead. */ export const inboundSchema = ForecastTick$inboundSchema; /** @deprecated use `ForecastTick$outboundSchema` instead. */ export const outboundSchema = ForecastTick$outboundSchema; /** @deprecated use `ForecastTick$Outbound` instead. */ export type Outbound = ForecastTick$Outbound; } export function forecastTickToJSON(forecastTick: ForecastTick): string { return JSON.stringify(ForecastTick$outboundSchema.parse(forecastTick)); } export function forecastTickFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ForecastTick$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ForecastTick' from JSON`, ); }