/* * 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 Asset = { symbol: string; type: string; assetClassSymbol: string; name: string; tickSize?: number | null | undefined; unit?: string | null | undefined; sku: string | null; code: string | null; priceFile: string | null; marketDate?: Date | null | undefined; exchange?: string | null | undefined; }; /** @internal */ export const Asset$inboundSchema: z.ZodType = z .object({ symbol: z.string(), type: z.string(), asset_class_symbol: z.string(), name: z.string(), tick_size: z.nullable(z.number()).optional(), unit: z.nullable(z.string()).optional(), sku: z.nullable(z.string()), code: z.nullable(z.string()), price_file: z.nullable(z.string()), market_date: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), exchange: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { "asset_class_symbol": "assetClassSymbol", "tick_size": "tickSize", "price_file": "priceFile", "market_date": "marketDate", }); }); /** @internal */ export type Asset$Outbound = { symbol: string; type: string; asset_class_symbol: string; name: string; tick_size?: number | null | undefined; unit?: string | null | undefined; sku: string | null; code: string | null; price_file: string | null; market_date?: string | null | undefined; exchange?: string | null | undefined; }; /** @internal */ export const Asset$outboundSchema: z.ZodType< Asset$Outbound, z.ZodTypeDef, Asset > = z.object({ symbol: z.string(), type: z.string(), assetClassSymbol: z.string(), name: z.string(), tickSize: z.nullable(z.number()).optional(), unit: z.nullable(z.string()).optional(), sku: z.nullable(z.string()), code: z.nullable(z.string()), priceFile: z.nullable(z.string()), marketDate: z.nullable(z.date().transform(v => v.toISOString())).optional(), exchange: z.nullable(z.string()).optional(), }).transform((v) => { return remap$(v, { assetClassSymbol: "asset_class_symbol", tickSize: "tick_size", priceFile: "price_file", 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 Asset$ { /** @deprecated use `Asset$inboundSchema` instead. */ export const inboundSchema = Asset$inboundSchema; /** @deprecated use `Asset$outboundSchema` instead. */ export const outboundSchema = Asset$outboundSchema; /** @deprecated use `Asset$Outbound` instead. */ export type Outbound = Asset$Outbound; } export function assetToJSON(asset: Asset): string { return JSON.stringify(Asset$outboundSchema.parse(asset)); } export function assetFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Asset$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Asset' from JSON`, ); }