/* * 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 Tick = { datetime: Date; open?: number | null | undefined; high?: number | null | undefined; low?: number | null | undefined; close?: number | null | undefined; volume: number; openInterest: number; change?: number | null | undefined; }; /** @internal */ export const Tick$inboundSchema: z.ZodType = z .object({ datetime: z.string().datetime({ offset: true }).transform(v => new Date(v)), open: z.nullable(z.number()).optional(), high: z.nullable(z.number()).optional(), low: z.nullable(z.number()).optional(), close: z.nullable(z.number()).optional(), volume: z.number().int(), open_interest: z.number().int(), change: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { "open_interest": "openInterest", }); }); /** @internal */ export type Tick$Outbound = { datetime: string; open?: number | null | undefined; high?: number | null | undefined; low?: number | null | undefined; close?: number | null | undefined; volume: number; open_interest: number; change?: number | null | undefined; }; /** @internal */ export const Tick$outboundSchema: z.ZodType = z.object({ datetime: z.date().transform(v => v.toISOString()), open: z.nullable(z.number()).optional(), high: z.nullable(z.number()).optional(), low: z.nullable(z.number()).optional(), close: z.nullable(z.number()).optional(), volume: z.number().int(), openInterest: z.number().int(), change: z.nullable(z.number()).optional(), }).transform((v) => { return remap$(v, { openInterest: "open_interest", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Tick$ { /** @deprecated use `Tick$inboundSchema` instead. */ export const inboundSchema = Tick$inboundSchema; /** @deprecated use `Tick$outboundSchema` instead. */ export const outboundSchema = Tick$outboundSchema; /** @deprecated use `Tick$Outbound` instead. */ export type Outbound = Tick$Outbound; } export function tickToJSON(tick: Tick): string { return JSON.stringify(Tick$outboundSchema.parse(tick)); } export function tickFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Tick$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Tick' from JSON`, ); }