/* * 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"; import { DecimalCreate, DecimalCreate$inboundSchema, DecimalCreate$Outbound, DecimalCreate$outboundSchema, } from "./decimalcreate.js"; /** * The type of fee being specified. Only the type of "BROKER_FEE" is supported. */ export enum FeeCreateType { 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 FeeCreateTypeOpen = OpenEnum; /** * A fee that applies to an order */ export type FeeCreate = { /** * 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 */ amount: DecimalCreate; /** * The type of fee being specified. Only the type of "BROKER_FEE" is supported. */ type: FeeCreateTypeOpen; }; /** @internal */ export const FeeCreateType$inboundSchema: z.ZodType< FeeCreateTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(FeeCreateType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const FeeCreateType$outboundSchema: z.ZodType< FeeCreateTypeOpen, z.ZodTypeDef, FeeCreateTypeOpen > = z.union([ z.nativeEnum(FeeCreateType), 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 FeeCreateType$ { /** @deprecated use `FeeCreateType$inboundSchema` instead. */ export const inboundSchema = FeeCreateType$inboundSchema; /** @deprecated use `FeeCreateType$outboundSchema` instead. */ export const outboundSchema = FeeCreateType$outboundSchema; } /** @internal */ export const FeeCreate$inboundSchema: z.ZodType< FeeCreate, z.ZodTypeDef, unknown > = z.object({ amount: DecimalCreate$inboundSchema, type: FeeCreateType$inboundSchema, }); /** @internal */ export type FeeCreate$Outbound = { amount: DecimalCreate$Outbound; type: string; }; /** @internal */ export const FeeCreate$outboundSchema: z.ZodType< FeeCreate$Outbound, z.ZodTypeDef, FeeCreate > = z.object({ amount: DecimalCreate$outboundSchema, type: FeeCreateType$outboundSchema, }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace FeeCreate$ { /** @deprecated use `FeeCreate$inboundSchema` instead. */ export const inboundSchema = FeeCreate$inboundSchema; /** @deprecated use `FeeCreate$outboundSchema` instead. */ export const outboundSchema = FeeCreate$outboundSchema; /** @deprecated use `FeeCreate$Outbound` instead. */ export type Outbound = FeeCreate$Outbound; } export function feeCreateToJSON(feeCreate: FeeCreate): string { return JSON.stringify(FeeCreate$outboundSchema.parse(feeCreate)); } export function feeCreateFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => FeeCreate$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'FeeCreate' from JSON`, ); }