/* * 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 { catchUnrecognizedEnum, OpenEnum, Unrecognized, } from "../../types/enums.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The fee amount. Not required if the fee is suppressed */ export type BookingFeeAmount = { /** * 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 */ export enum BookingFeeType { FeeTypeUnspecified = "FEE_TYPE_UNSPECIFIED", ClientClearing = "CLIENT_CLEARING", Liquidity = "LIQUIDITY", TradeActivity = "TRADE_ACTIVITY", FinancialTransactionTax = "FINANCIAL_TRANSACTION_TAX", IndexOptionFee = "INDEX_OPTION_FEE", SecFee = "SEC_FEE", OptionsRegulatory = "OPTIONS_REGULATORY", GeneralPurposeFee = "GENERAL_PURPOSE_FEE", BrokerFee = "BROKER_FEE", ContractFee = "CONTRACT_FEE", OccFee = "OCC_FEE", } /** * The type of fee */ export type BookingFeeTypeOpen = OpenEnum; /** * Fee message includes both fee type as well as the fee amount */ export type BookingFee = { /** * The fee amount. Not required if the fee is suppressed */ amount?: BookingFeeAmount | null | undefined; /** * Indicates whether to explicitly suppress this fee type. If the trade would normally calculate fees (e.g., for TRADE_ACTIVITY), the client can add a fee with this boolean value set to true, and the Booking Service will not calculate or assess that fee on the trade. */ suppressFee?: boolean | undefined; /** * The type of fee */ type?: BookingFeeTypeOpen | undefined; }; /** @internal */ export const BookingFeeAmount$inboundSchema: z.ZodType< BookingFeeAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BookingFeeAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const BookingFeeAmount$outboundSchema: z.ZodType< BookingFeeAmount$Outbound, z.ZodTypeDef, BookingFeeAmount > = 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 BookingFeeAmount$ { /** @deprecated use `BookingFeeAmount$inboundSchema` instead. */ export const inboundSchema = BookingFeeAmount$inboundSchema; /** @deprecated use `BookingFeeAmount$outboundSchema` instead. */ export const outboundSchema = BookingFeeAmount$outboundSchema; /** @deprecated use `BookingFeeAmount$Outbound` instead. */ export type Outbound = BookingFeeAmount$Outbound; } export function bookingFeeAmountToJSON( bookingFeeAmount: BookingFeeAmount, ): string { return JSON.stringify( BookingFeeAmount$outboundSchema.parse(bookingFeeAmount), ); } export function bookingFeeAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BookingFeeAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BookingFeeAmount' from JSON`, ); } /** @internal */ export const BookingFeeType$inboundSchema: z.ZodType< BookingFeeTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BookingFeeType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BookingFeeType$outboundSchema: z.ZodType< BookingFeeTypeOpen, z.ZodTypeDef, BookingFeeTypeOpen > = z.union([ z.nativeEnum(BookingFeeType), 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 BookingFeeType$ { /** @deprecated use `BookingFeeType$inboundSchema` instead. */ export const inboundSchema = BookingFeeType$inboundSchema; /** @deprecated use `BookingFeeType$outboundSchema` instead. */ export const outboundSchema = BookingFeeType$outboundSchema; } /** @internal */ export const BookingFee$inboundSchema: z.ZodType< BookingFee, z.ZodTypeDef, unknown > = z.object({ amount: z.nullable(z.lazy(() => BookingFeeAmount$inboundSchema)).optional(), suppress_fee: z.boolean().optional(), type: BookingFeeType$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "suppress_fee": "suppressFee", }); }); /** @internal */ export type BookingFee$Outbound = { amount?: BookingFeeAmount$Outbound | null | undefined; suppress_fee?: boolean | undefined; type?: string | undefined; }; /** @internal */ export const BookingFee$outboundSchema: z.ZodType< BookingFee$Outbound, z.ZodTypeDef, BookingFee > = z.object({ amount: z.nullable(z.lazy(() => BookingFeeAmount$outboundSchema)).optional(), suppressFee: z.boolean().optional(), type: BookingFeeType$outboundSchema.optional(), }).transform((v) => { return remap$(v, { suppressFee: "suppress_fee", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BookingFee$ { /** @deprecated use `BookingFee$inboundSchema` instead. */ export const inboundSchema = BookingFee$inboundSchema; /** @deprecated use `BookingFee$outboundSchema` instead. */ export const outboundSchema = BookingFee$outboundSchema; /** @deprecated use `BookingFee$Outbound` instead. */ export type Outbound = BookingFee$Outbound; } export function bookingFeeToJSON(bookingFee: BookingFee): string { return JSON.stringify(BookingFee$outboundSchema.parse(bookingFee)); } export function bookingFeeFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BookingFee$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BookingFee' from JSON`, ); }