/* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The amount of the fee. This is a monetary value in the same currency as the order. */ export type TradingFeeAmount = { /** * The decimal value, as a string; Refer to [Google’s Decimal type protocol buffer](https://github.com/googleapis/googleapis/blob/40203ca1880849480bbff7b8715491060bbccdf1/google/type/decimal.proto#L33) for details */ value?: string | undefined; }; /** * The type of fee being specified. Only the type of "BROKER_FEE" is supported. */ export enum TradingFeeType { FeeTypeUnspecified = "FEE_TYPE_UNSPECIFIED", BrokerFee = "BROKER_FEE", ContractFee = "CONTRACT_FEE", } /** * The type of fee being specified. Only the type of "BROKER_FEE" is supported. */ export type TradingFeeTypeOpen = OpenEnum; /** * A fee that applies to an order */ export type TradingFee = { /** * The amount of the fee. This is a monetary value in the same currency as the order. */ amount?: TradingFeeAmount | null | undefined; /** * The type of fee being specified. Only the type of "BROKER_FEE" is supported. */ type?: TradingFeeTypeOpen | undefined; }; /** @internal */ export const TradingFeeAmount$inboundSchema: z.ZodType< TradingFeeAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type TradingFeeAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const TradingFeeAmount$outboundSchema: z.ZodType< TradingFeeAmount$Outbound, z.ZodTypeDef, TradingFeeAmount > = z.object({ value: z.string().optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TradingFeeAmount$ { /** @deprecated use `TradingFeeAmount$inboundSchema` instead. */ export const inboundSchema = TradingFeeAmount$inboundSchema; /** @deprecated use `TradingFeeAmount$outboundSchema` instead. */ export const outboundSchema = TradingFeeAmount$outboundSchema; /** @deprecated use `TradingFeeAmount$Outbound` instead. */ export type Outbound = TradingFeeAmount$Outbound; } export function tradingFeeAmountToJSON( tradingFeeAmount: TradingFeeAmount, ): string { return JSON.stringify( TradingFeeAmount$outboundSchema.parse(tradingFeeAmount), ); } export function tradingFeeAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TradingFeeAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TradingFeeAmount' from JSON`, ); } /** @internal */ export const TradingFeeType$inboundSchema: z.ZodType< TradingFeeTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(TradingFeeType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const TradingFeeType$outboundSchema: z.ZodType< TradingFeeTypeOpen, z.ZodTypeDef, TradingFeeTypeOpen > = z.union([ z.nativeEnum(TradingFeeType), z.string().and(z.custom>()), ]); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TradingFeeType$ { /** @deprecated use `TradingFeeType$inboundSchema` instead. */ export const inboundSchema = TradingFeeType$inboundSchema; /** @deprecated use `TradingFeeType$outboundSchema` instead. */ export const outboundSchema = TradingFeeType$outboundSchema; } /** @internal */ export const TradingFee$inboundSchema: z.ZodType< TradingFee, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => TradingFeeAmount$inboundSchema)).optional(), type: TradingFeeType$inboundSchema.optional(), }); /** @internal */ export type TradingFee$Outbound = { amount?: TradingFeeAmount$Outbound | null | undefined; type?: string | undefined; }; /** @internal */ export const TradingFee$outboundSchema: z.ZodType< TradingFee$Outbound, z.ZodTypeDef, TradingFee > = z.object({ amount: z.nullable(z.lazy(() => TradingFeeAmount$outboundSchema)).optional(), type: TradingFeeType$outboundSchema.optional(), }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace TradingFee$ { /** @deprecated use `TradingFee$inboundSchema` instead. */ export const inboundSchema = TradingFee$inboundSchema; /** @deprecated use `TradingFee$outboundSchema` instead. */ export const outboundSchema = TradingFee$outboundSchema; /** @deprecated use `TradingFee$Outbound` instead. */ export type Outbound = TradingFee$Outbound; } export function tradingFeeToJSON(tradingFee: TradingFee): string { return JSON.stringify(TradingFee$outboundSchema.parse(tradingFee)); } export function tradingFeeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => TradingFee$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'TradingFee' from JSON`, ); }