/* * 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"; import { Asset, Asset$inboundSchema, Asset$Outbound, Asset$outboundSchema, } from "./asset.js"; import { ContractWithPriceTicks, ContractWithPriceTicks$inboundSchema, ContractWithPriceTicks$Outbound, ContractWithPriceTicks$outboundSchema, } from "./contractwithpriceticks.js"; export type AssetPriceData = { asset: Asset; frontMonth: string; marketDate?: Date | null | undefined; contracts: Array; }; /** @internal */ export const AssetPriceData$inboundSchema: z.ZodType< AssetPriceData, z.ZodTypeDef, unknown > = z.object({ asset: Asset$inboundSchema, front_month: z.string(), market_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), contracts: z.array(ContractWithPriceTicks$inboundSchema), }).transform((v) => { return remap$(v, { "front_month": "frontMonth", "market_date": "marketDate", }); }); /** @internal */ export type AssetPriceData$Outbound = { asset: Asset$Outbound; front_month: string; market_date?: string | null | undefined; contracts: Array; }; /** @internal */ export const AssetPriceData$outboundSchema: z.ZodType< AssetPriceData$Outbound, z.ZodTypeDef, AssetPriceData > = z.object({ asset: Asset$outboundSchema, frontMonth: z.string(), marketDate: z.nullable(z.date().transform(v => v.toISOString())).optional(), contracts: z.array(ContractWithPriceTicks$outboundSchema), }).transform((v) => { return remap$(v, { frontMonth: "front_month", marketDate: "market_date", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace AssetPriceData$ { /** @deprecated use `AssetPriceData$inboundSchema` instead. */ export const inboundSchema = AssetPriceData$inboundSchema; /** @deprecated use `AssetPriceData$outboundSchema` instead. */ export const outboundSchema = AssetPriceData$outboundSchema; /** @deprecated use `AssetPriceData$Outbound` instead. */ export type Outbound = AssetPriceData$Outbound; } export function assetPriceDataToJSON(assetPriceData: AssetPriceData): string { return JSON.stringify(AssetPriceData$outboundSchema.parse(assetPriceData)); } export function assetPriceDataFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AssetPriceData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AssetPriceData' from JSON`, ); }