/* * 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 processing status of the basket */ export enum BasketState { StateUnspecified = "STATE_UNSPECIFIED", New = "NEW", Submitted = "SUBMITTED", Executing = "EXECUTING", Allocating = "ALLOCATING", Done = "DONE", Rejected = "REJECTED", PartiallyFilled = "PARTIALLY_FILLED", } /** * The processing status of the basket */ export type BasketStateOpen = OpenEnum; /** * The message describing a basket */ export type Basket = { /** * System generated unique id for the basket */ basketId?: string | undefined; /** * Number of orders in the basket */ basketOrderCount?: string | undefined; /** * The processing status of the basket */ basketState?: BasketStateOpen | undefined; /** * User-supplied unique basket ID. Cannot be more than 40 characters long. */ clientBasketId?: string | undefined; /** * Time the basket submission request was sent by the client. This is a situationally optional field that reflects the value provided by the user in the SubmitBasketRequest. */ clientBasketSubmitTime?: Date | null | undefined; /** * Time the basket was completed */ completeTime?: Date | null | undefined; /** * Number of compressed orders in the basket that will go to market. This number is calculated after basket submission. */ compressedOrderCount?: string | undefined; /** * The unique id for the correspondent for the basket */ correspondentId?: string | undefined; /** * Time of the basket creation */ createTime?: Date | null | undefined; /** * Number of distinct accounts in the basket. */ distinctAccountCount?: string | undefined; /** * Time of the last basket update */ lastUpdateTime?: Date | null | undefined; /** * System generated name of the basket */ name?: string | undefined; /** * Number of accounts that did not pass risk checks and their orders were rejected. */ rejectedAccountCount?: string | undefined; /** * Time the basket was submitted */ submitTime?: Date | null | undefined; }; /** @internal */ export const BasketState$inboundSchema: z.ZodType< BasketStateOpen, z.ZodTypeDef, unknown > = z .union([ z.nativeEnum(BasketState), z.string().transform(catchUnrecognizedEnum), ]); /** @internal */ export const BasketState$outboundSchema: z.ZodType< BasketStateOpen, z.ZodTypeDef, BasketStateOpen > = z.union([ z.nativeEnum(BasketState), 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 BasketState$ { /** @deprecated use `BasketState$inboundSchema` instead. */ export const inboundSchema = BasketState$inboundSchema; /** @deprecated use `BasketState$outboundSchema` instead. */ export const outboundSchema = BasketState$outboundSchema; } /** @internal */ export const Basket$inboundSchema: z.ZodType = z .object({ basket_id: z.string().optional(), basket_order_count: z.string().optional(), basket_state: BasketState$inboundSchema.optional(), client_basket_id: z.string().optional(), client_basket_submit_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), complete_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), compressed_order_count: z.string().optional(), correspondent_id: z.string().optional(), create_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), distinct_account_count: z.string().optional(), last_update_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), name: z.string().optional(), rejected_account_count: z.string().optional(), submit_time: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "basket_id": "basketId", "basket_order_count": "basketOrderCount", "basket_state": "basketState", "client_basket_id": "clientBasketId", "client_basket_submit_time": "clientBasketSubmitTime", "complete_time": "completeTime", "compressed_order_count": "compressedOrderCount", "correspondent_id": "correspondentId", "create_time": "createTime", "distinct_account_count": "distinctAccountCount", "last_update_time": "lastUpdateTime", "rejected_account_count": "rejectedAccountCount", "submit_time": "submitTime", }); }); /** @internal */ export type Basket$Outbound = { basket_id?: string | undefined; basket_order_count?: string | undefined; basket_state?: string | undefined; client_basket_id?: string | undefined; client_basket_submit_time?: string | null | undefined; complete_time?: string | null | undefined; compressed_order_count?: string | undefined; correspondent_id?: string | undefined; create_time?: string | null | undefined; distinct_account_count?: string | undefined; last_update_time?: string | null | undefined; name?: string | undefined; rejected_account_count?: string | undefined; submit_time?: string | null | undefined; }; /** @internal */ export const Basket$outboundSchema: z.ZodType< Basket$Outbound, z.ZodTypeDef, Basket > = z.object({ basketId: z.string().optional(), basketOrderCount: z.string().optional(), basketState: BasketState$outboundSchema.optional(), clientBasketId: z.string().optional(), clientBasketSubmitTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), completeTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), compressedOrderCount: z.string().optional(), correspondentId: z.string().optional(), createTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), distinctAccountCount: z.string().optional(), lastUpdateTime: z.nullable(z.date().transform(v => v.toISOString())) .optional(), name: z.string().optional(), rejectedAccountCount: z.string().optional(), submitTime: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { basketId: "basket_id", basketOrderCount: "basket_order_count", basketState: "basket_state", clientBasketId: "client_basket_id", clientBasketSubmitTime: "client_basket_submit_time", completeTime: "complete_time", compressedOrderCount: "compressed_order_count", correspondentId: "correspondent_id", createTime: "create_time", distinctAccountCount: "distinct_account_count", lastUpdateTime: "last_update_time", rejectedAccountCount: "rejected_account_count", submitTime: "submit_time", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace Basket$ { /** @deprecated use `Basket$inboundSchema` instead. */ export const inboundSchema = Basket$inboundSchema; /** @deprecated use `Basket$outboundSchema` instead. */ export const outboundSchema = Basket$outboundSchema; /** @deprecated use `Basket$Outbound` instead. */ export type Outbound = Basket$Outbound; } export function basketToJSON(basket: Basket): string { return JSON.stringify(Basket$outboundSchema.parse(basket)); } export function basketFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => Basket$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Basket' from JSON`, ); }