/* * 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"; import { BidAskPrice, BidAskPrice$inboundSchema, BidAskPrice$Outbound, BidAskPrice$outboundSchema, } from "./bidaskprice.js"; /** * The best ask minimum quantity. This will be absent if no ask information is available */ export type AskMinimumQuantity = { /** * 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 best ask quantity. This will be absent if no ask information is available */ export type AskQuantity = { /** * 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 asset referenced by the security identifier */ export enum RetrieveQuoteResponseAssetType { AssetTypeUnspecified = "ASSET_TYPE_UNSPECIFIED", Equity = "EQUITY", FixedIncome = "FIXED_INCOME", MutualFund = "MUTUAL_FUND", Option = "OPTION", EventContract = "EVENT_CONTRACT", } /** * The type of asset referenced by the security identifier */ export type RetrieveQuoteResponseAssetTypeOpen = OpenEnum< typeof RetrieveQuoteResponseAssetType >; /** * The best bid minimum quantity. This will be absent if no bid information is available */ export type BidMinimumQuantity = { /** * 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 best bid quantity. This will be absent if no bid information is available */ export type BidQuantity = { /** * 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; }; /** * Capacity used in determining bid and ask prices. Defaults to "AGENCY" if no value specified. */ export enum RetrieveQuoteResponseBrokerCapacity { BrokerCapacityUnspecified = "BROKER_CAPACITY_UNSPECIFIED", Agency = "AGENCY", Principal = "PRINCIPAL", } /** * Capacity used in determining bid and ask prices. Defaults to "AGENCY" if no value specified. */ export type RetrieveQuoteResponseBrokerCapacityOpen = OpenEnum< typeof RetrieveQuoteResponseBrokerCapacity >; /** * The identifier type of the asset for which the best bid and offer is returned. This will be the same value as what was sent on the request. */ export enum RetrieveQuoteResponseIdentifierType { AssetId = "ASSET_ID", Cusip = "CUSIP", Isin = "ISIN", } /** * The identifier type of the asset for which the best bid and offer is returned. This will be the same value as what was sent on the request. */ export type RetrieveQuoteResponseIdentifierTypeOpen = OpenEnum< typeof RetrieveQuoteResponseIdentifierType >; /** * The minimum quantity specified in the request (if any). For Fixed Income: Expressed in the par (face-value) amount and may not exceed two decimal places for USD-based currencies. */ export type MinimumQuantity = { /** * 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 current best bid and offer for a specified security */ export type RetrieveQuoteResponse = { /** * The account id used in calculating order costs */ accountId?: string | undefined; /** * The best ask minimum quantity. This will be absent if no ask information is available */ askMinimumQuantity?: AskMinimumQuantity | null | undefined; /** * The price information of the best ask matching the request criteria. If no ask information is available at all, this will be empty. If yield information is not available, then this will only contain a PERCENTAGE_OF_PAR-typed price. */ askPrices?: Array | undefined; /** * The best ask quantity. This will be absent if no ask information is available */ askQuantity?: AskQuantity | null | undefined; /** * Apex Asset ID for this asset. */ assetId?: string | undefined; /** * The type of asset referenced by the security identifier */ assetType?: RetrieveQuoteResponseAssetTypeOpen | undefined; /** * The best bid minimum quantity. This will be absent if no bid information is available */ bidMinimumQuantity?: BidMinimumQuantity | null | undefined; /** * The price information of the best bid matching the request criteria. If no bid information is available at all, this will be empty. If yield information is not available, then this will only contain a PERCENTAGE_OF_PAR-typed price. */ bidPrices?: Array | undefined; /** * The best bid quantity. This will be absent if no bid information is available */ bidQuantity?: BidQuantity | null | undefined; /** * Capacity used in determining bid and ask prices. Defaults to "AGENCY" if no value specified. */ brokerCapacity?: RetrieveQuoteResponseBrokerCapacityOpen | undefined; /** * Identifier of the asset (of the type specified in `identifier_type`). */ identifier?: string | undefined; /** * The identifier type of the asset for which the best bid and offer is returned. This will be the same value as what was sent on the request. */ identifierType?: RetrieveQuoteResponseIdentifierTypeOpen | undefined; /** * The minimum quantity specified in the request (if any). For Fixed Income: Expressed in the par (face-value) amount and may not exceed two decimal places for USD-based currencies. */ minimumQuantity?: MinimumQuantity | null | undefined; /** * The time the response was generated by the system */ responseGenerationTime?: Date | null | undefined; }; /** @internal */ export const AskMinimumQuantity$inboundSchema: z.ZodType< AskMinimumQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type AskMinimumQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const AskMinimumQuantity$outboundSchema: z.ZodType< AskMinimumQuantity$Outbound, z.ZodTypeDef, AskMinimumQuantity > = 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 AskMinimumQuantity$ { /** @deprecated use `AskMinimumQuantity$inboundSchema` instead. */ export const inboundSchema = AskMinimumQuantity$inboundSchema; /** @deprecated use `AskMinimumQuantity$outboundSchema` instead. */ export const outboundSchema = AskMinimumQuantity$outboundSchema; /** @deprecated use `AskMinimumQuantity$Outbound` instead. */ export type Outbound = AskMinimumQuantity$Outbound; } export function askMinimumQuantityToJSON( askMinimumQuantity: AskMinimumQuantity, ): string { return JSON.stringify( AskMinimumQuantity$outboundSchema.parse(askMinimumQuantity), ); } export function askMinimumQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AskMinimumQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AskMinimumQuantity' from JSON`, ); } /** @internal */ export const AskQuantity$inboundSchema: z.ZodType< AskQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type AskQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const AskQuantity$outboundSchema: z.ZodType< AskQuantity$Outbound, z.ZodTypeDef, AskQuantity > = 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 AskQuantity$ { /** @deprecated use `AskQuantity$inboundSchema` instead. */ export const inboundSchema = AskQuantity$inboundSchema; /** @deprecated use `AskQuantity$outboundSchema` instead. */ export const outboundSchema = AskQuantity$outboundSchema; /** @deprecated use `AskQuantity$Outbound` instead. */ export type Outbound = AskQuantity$Outbound; } export function askQuantityToJSON(askQuantity: AskQuantity): string { return JSON.stringify(AskQuantity$outboundSchema.parse(askQuantity)); } export function askQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => AskQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'AskQuantity' from JSON`, ); } /** @internal */ export const RetrieveQuoteResponseAssetType$inboundSchema: z.ZodType< RetrieveQuoteResponseAssetTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(RetrieveQuoteResponseAssetType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const RetrieveQuoteResponseAssetType$outboundSchema: z.ZodType< RetrieveQuoteResponseAssetTypeOpen, z.ZodTypeDef, RetrieveQuoteResponseAssetTypeOpen > = z.union([ z.nativeEnum(RetrieveQuoteResponseAssetType), 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 RetrieveQuoteResponseAssetType$ { /** @deprecated use `RetrieveQuoteResponseAssetType$inboundSchema` instead. */ export const inboundSchema = RetrieveQuoteResponseAssetType$inboundSchema; /** @deprecated use `RetrieveQuoteResponseAssetType$outboundSchema` instead. */ export const outboundSchema = RetrieveQuoteResponseAssetType$outboundSchema; } /** @internal */ export const BidMinimumQuantity$inboundSchema: z.ZodType< BidMinimumQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BidMinimumQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const BidMinimumQuantity$outboundSchema: z.ZodType< BidMinimumQuantity$Outbound, z.ZodTypeDef, BidMinimumQuantity > = 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 BidMinimumQuantity$ { /** @deprecated use `BidMinimumQuantity$inboundSchema` instead. */ export const inboundSchema = BidMinimumQuantity$inboundSchema; /** @deprecated use `BidMinimumQuantity$outboundSchema` instead. */ export const outboundSchema = BidMinimumQuantity$outboundSchema; /** @deprecated use `BidMinimumQuantity$Outbound` instead. */ export type Outbound = BidMinimumQuantity$Outbound; } export function bidMinimumQuantityToJSON( bidMinimumQuantity: BidMinimumQuantity, ): string { return JSON.stringify( BidMinimumQuantity$outboundSchema.parse(bidMinimumQuantity), ); } export function bidMinimumQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BidMinimumQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BidMinimumQuantity' from JSON`, ); } /** @internal */ export const BidQuantity$inboundSchema: z.ZodType< BidQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type BidQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const BidQuantity$outboundSchema: z.ZodType< BidQuantity$Outbound, z.ZodTypeDef, BidQuantity > = 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 BidQuantity$ { /** @deprecated use `BidQuantity$inboundSchema` instead. */ export const inboundSchema = BidQuantity$inboundSchema; /** @deprecated use `BidQuantity$outboundSchema` instead. */ export const outboundSchema = BidQuantity$outboundSchema; /** @deprecated use `BidQuantity$Outbound` instead. */ export type Outbound = BidQuantity$Outbound; } export function bidQuantityToJSON(bidQuantity: BidQuantity): string { return JSON.stringify(BidQuantity$outboundSchema.parse(bidQuantity)); } export function bidQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BidQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BidQuantity' from JSON`, ); } /** @internal */ export const RetrieveQuoteResponseBrokerCapacity$inboundSchema: z.ZodType< RetrieveQuoteResponseBrokerCapacityOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(RetrieveQuoteResponseBrokerCapacity), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const RetrieveQuoteResponseBrokerCapacity$outboundSchema: z.ZodType< RetrieveQuoteResponseBrokerCapacityOpen, z.ZodTypeDef, RetrieveQuoteResponseBrokerCapacityOpen > = z.union([ z.nativeEnum(RetrieveQuoteResponseBrokerCapacity), 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 RetrieveQuoteResponseBrokerCapacity$ { /** @deprecated use `RetrieveQuoteResponseBrokerCapacity$inboundSchema` instead. */ export const inboundSchema = RetrieveQuoteResponseBrokerCapacity$inboundSchema; /** @deprecated use `RetrieveQuoteResponseBrokerCapacity$outboundSchema` instead. */ export const outboundSchema = RetrieveQuoteResponseBrokerCapacity$outboundSchema; } /** @internal */ export const RetrieveQuoteResponseIdentifierType$inboundSchema: z.ZodType< RetrieveQuoteResponseIdentifierTypeOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(RetrieveQuoteResponseIdentifierType), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const RetrieveQuoteResponseIdentifierType$outboundSchema: z.ZodType< RetrieveQuoteResponseIdentifierTypeOpen, z.ZodTypeDef, RetrieveQuoteResponseIdentifierTypeOpen > = z.union([ z.nativeEnum(RetrieveQuoteResponseIdentifierType), 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 RetrieveQuoteResponseIdentifierType$ { /** @deprecated use `RetrieveQuoteResponseIdentifierType$inboundSchema` instead. */ export const inboundSchema = RetrieveQuoteResponseIdentifierType$inboundSchema; /** @deprecated use `RetrieveQuoteResponseIdentifierType$outboundSchema` instead. */ export const outboundSchema = RetrieveQuoteResponseIdentifierType$outboundSchema; } /** @internal */ export const MinimumQuantity$inboundSchema: z.ZodType< MinimumQuantity, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type MinimumQuantity$Outbound = { value?: string | undefined; }; /** @internal */ export const MinimumQuantity$outboundSchema: z.ZodType< MinimumQuantity$Outbound, z.ZodTypeDef, MinimumQuantity > = 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 MinimumQuantity$ { /** @deprecated use `MinimumQuantity$inboundSchema` instead. */ export const inboundSchema = MinimumQuantity$inboundSchema; /** @deprecated use `MinimumQuantity$outboundSchema` instead. */ export const outboundSchema = MinimumQuantity$outboundSchema; /** @deprecated use `MinimumQuantity$Outbound` instead. */ export type Outbound = MinimumQuantity$Outbound; } export function minimumQuantityToJSON( minimumQuantity: MinimumQuantity, ): string { return JSON.stringify(MinimumQuantity$outboundSchema.parse(minimumQuantity)); } export function minimumQuantityFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => MinimumQuantity$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'MinimumQuantity' from JSON`, ); } /** @internal */ export const RetrieveQuoteResponse$inboundSchema: z.ZodType< RetrieveQuoteResponse, z.ZodTypeDef, unknown > = z.object({ account_id: z.string().optional(), ask_minimum_quantity: z.nullable( z.lazy(() => AskMinimumQuantity$inboundSchema), ).optional(), ask_prices: z.array(BidAskPrice$inboundSchema).optional(), ask_quantity: z.nullable(z.lazy(() => AskQuantity$inboundSchema)).optional(), asset_id: z.string().optional(), asset_type: RetrieveQuoteResponseAssetType$inboundSchema.optional(), bid_minimum_quantity: z.nullable( z.lazy(() => BidMinimumQuantity$inboundSchema), ).optional(), bid_prices: z.array(BidAskPrice$inboundSchema).optional(), bid_quantity: z.nullable(z.lazy(() => BidQuantity$inboundSchema)).optional(), broker_capacity: RetrieveQuoteResponseBrokerCapacity$inboundSchema.optional(), identifier: z.string().optional(), identifier_type: RetrieveQuoteResponseIdentifierType$inboundSchema.optional(), minimum_quantity: z.nullable(z.lazy(() => MinimumQuantity$inboundSchema)) .optional(), response_generation_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "account_id": "accountId", "ask_minimum_quantity": "askMinimumQuantity", "ask_prices": "askPrices", "ask_quantity": "askQuantity", "asset_id": "assetId", "asset_type": "assetType", "bid_minimum_quantity": "bidMinimumQuantity", "bid_prices": "bidPrices", "bid_quantity": "bidQuantity", "broker_capacity": "brokerCapacity", "identifier_type": "identifierType", "minimum_quantity": "minimumQuantity", "response_generation_time": "responseGenerationTime", }); }); /** @internal */ export type RetrieveQuoteResponse$Outbound = { account_id?: string | undefined; ask_minimum_quantity?: AskMinimumQuantity$Outbound | null | undefined; ask_prices?: Array | undefined; ask_quantity?: AskQuantity$Outbound | null | undefined; asset_id?: string | undefined; asset_type?: string | undefined; bid_minimum_quantity?: BidMinimumQuantity$Outbound | null | undefined; bid_prices?: Array | undefined; bid_quantity?: BidQuantity$Outbound | null | undefined; broker_capacity?: string | undefined; identifier?: string | undefined; identifier_type?: string | undefined; minimum_quantity?: MinimumQuantity$Outbound | null | undefined; response_generation_time?: string | null | undefined; }; /** @internal */ export const RetrieveQuoteResponse$outboundSchema: z.ZodType< RetrieveQuoteResponse$Outbound, z.ZodTypeDef, RetrieveQuoteResponse > = z.object({ accountId: z.string().optional(), askMinimumQuantity: z.nullable( z.lazy(() => AskMinimumQuantity$outboundSchema), ).optional(), askPrices: z.array(BidAskPrice$outboundSchema).optional(), askQuantity: z.nullable(z.lazy(() => AskQuantity$outboundSchema)).optional(), assetId: z.string().optional(), assetType: RetrieveQuoteResponseAssetType$outboundSchema.optional(), bidMinimumQuantity: z.nullable( z.lazy(() => BidMinimumQuantity$outboundSchema), ).optional(), bidPrices: z.array(BidAskPrice$outboundSchema).optional(), bidQuantity: z.nullable(z.lazy(() => BidQuantity$outboundSchema)).optional(), brokerCapacity: RetrieveQuoteResponseBrokerCapacity$outboundSchema.optional(), identifier: z.string().optional(), identifierType: RetrieveQuoteResponseIdentifierType$outboundSchema.optional(), minimumQuantity: z.nullable(z.lazy(() => MinimumQuantity$outboundSchema)) .optional(), responseGenerationTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), }).transform((v) => { return remap$(v, { accountId: "account_id", askMinimumQuantity: "ask_minimum_quantity", askPrices: "ask_prices", askQuantity: "ask_quantity", assetId: "asset_id", assetType: "asset_type", bidMinimumQuantity: "bid_minimum_quantity", bidPrices: "bid_prices", bidQuantity: "bid_quantity", brokerCapacity: "broker_capacity", identifierType: "identifier_type", minimumQuantity: "minimum_quantity", responseGenerationTime: "response_generation_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace RetrieveQuoteResponse$ { /** @deprecated use `RetrieveQuoteResponse$inboundSchema` instead. */ export const inboundSchema = RetrieveQuoteResponse$inboundSchema; /** @deprecated use `RetrieveQuoteResponse$outboundSchema` instead. */ export const outboundSchema = RetrieveQuoteResponse$outboundSchema; /** @deprecated use `RetrieveQuoteResponse$Outbound` instead. */ export type Outbound = RetrieveQuoteResponse$Outbound; } export function retrieveQuoteResponseToJSON( retrieveQuoteResponse: RetrieveQuoteResponse, ): string { return JSON.stringify( RetrieveQuoteResponse$outboundSchema.parse(retrieveQuoteResponse), ); } export function retrieveQuoteResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => RetrieveQuoteResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'RetrieveQuoteResponse' from JSON`, ); }