/* * 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 { DateCreate, DateCreate$inboundSchema, DateCreate$Outbound, DateCreate$outboundSchema, } from "./datecreate.js"; import { DecimalCreate, DecimalCreate$inboundSchema, DecimalCreate$Outbound, DecimalCreate$outboundSchema, } from "./decimalcreate.js"; /** * Deprecated; use the price field instead * * @deprecated class: This will be removed in a future release, please migrate away from it as soon as possible. */ export type Money = { currencyCode?: string | undefined; /** * A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java's [BigDecimal][] or Python's [decimal.Decimal][]. * * @remarks * * [BigDecimal]: * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html * [decimal.Decimal]: https://docs.python.org/3/library/decimal.html */ price?: DecimalCreate | undefined; }; /** * For use in specifying lot matching instructions on a trade */ export type LotCreate = { /** * User-specified ID for the lot */ id?: string | undefined; /** * Deprecated; use the price field instead * * @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible. */ money?: Money | undefined; /** * A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java's [BigDecimal][] or Python's [decimal.Decimal][]. * * @remarks * * [BigDecimal]: * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html * [decimal.Decimal]: https://docs.python.org/3/library/decimal.html */ price?: DecimalCreate | undefined; /** * A representation of a decimal value, such as 2.5. Clients may convert values into language-native decimal formats, such as Java's [BigDecimal][] or Python's [decimal.Decimal][]. * * @remarks * * [BigDecimal]: * https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/math/BigDecimal.html * [decimal.Decimal]: https://docs.python.org/3/library/decimal.html */ quantity?: DecimalCreate | undefined; /** * Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * * @remarks * * * A full date, with non-zero year, month, and day values * A month and day value, with a zero year, such as an anniversary * A year on its own, with zero month and day values * A year and month value, with a zero day, such as a credit card expiration date * * Related types are [google.type.TimeOfDay][google.type.TimeOfDay] and `google.protobuf.Timestamp`. */ tradeDate?: DateCreate | undefined; }; /** @internal */ export const Money$inboundSchema: z.ZodType = z .object({ currency_code: z.string().optional(), price: DecimalCreate$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "currency_code": "currencyCode", }); }); /** @internal */ export type Money$Outbound = { currency_code?: string | undefined; price?: DecimalCreate$Outbound | undefined; }; /** @internal */ export const Money$outboundSchema: z.ZodType< Money$Outbound, z.ZodTypeDef, Money > = z.object({ currencyCode: z.string().optional(), price: DecimalCreate$outboundSchema.optional(), }).transform((v) => { return remap$(v, { currencyCode: "currency_code", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Money$ { /** @deprecated use `Money$inboundSchema` instead. */ export const inboundSchema = Money$inboundSchema; /** @deprecated use `Money$outboundSchema` instead. */ export const outboundSchema = Money$outboundSchema; /** @deprecated use `Money$Outbound` instead. */ export type Outbound = Money$Outbound; } export function moneyToJSON(money: Money): string { return JSON.stringify(Money$outboundSchema.parse(money)); } export function moneyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Money$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Money' from JSON`, ); } /** @internal */ export const LotCreate$inboundSchema: z.ZodType< LotCreate, z.ZodTypeDef, unknown > = z.object({ id: z.string().optional(), money: z.lazy(() => Money$inboundSchema).optional(), price: DecimalCreate$inboundSchema.optional(), quantity: DecimalCreate$inboundSchema.optional(), trade_date: DateCreate$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "trade_date": "tradeDate", }); }); /** @internal */ export type LotCreate$Outbound = { id?: string | undefined; money?: Money$Outbound | undefined; price?: DecimalCreate$Outbound | undefined; quantity?: DecimalCreate$Outbound | undefined; trade_date?: DateCreate$Outbound | undefined; }; /** @internal */ export const LotCreate$outboundSchema: z.ZodType< LotCreate$Outbound, z.ZodTypeDef, LotCreate > = z.object({ id: z.string().optional(), money: z.lazy(() => Money$outboundSchema).optional(), price: DecimalCreate$outboundSchema.optional(), quantity: DecimalCreate$outboundSchema.optional(), tradeDate: DateCreate$outboundSchema.optional(), }).transform((v) => { return remap$(v, { tradeDate: "trade_date", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace LotCreate$ { /** @deprecated use `LotCreate$inboundSchema` instead. */ export const inboundSchema = LotCreate$inboundSchema; /** @deprecated use `LotCreate$outboundSchema` instead. */ export const outboundSchema = LotCreate$outboundSchema; /** @deprecated use `LotCreate$Outbound` instead. */ export type Outbound = LotCreate$Outbound; } export function lotCreateToJSON(lotCreate: LotCreate): string { return JSON.stringify(LotCreate$outboundSchema.parse(lotCreate)); } export function lotCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => LotCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'LotCreate' from JSON`, ); }