/* * 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 { Result as SafeParseResult } from "../../types/fp.js"; import * as components from "../components/index.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type BookingCreateTradeRequest = { /** * The account id. */ accountId: string; tradeCreate: components.TradeCreate; }; export type BookingCreateTradeResponse = { httpMeta: components.HTTPMetadata; /** * OK */ bookingTrade?: components.BookingTrade | undefined; /** * FAILED_PRECONDITION: The operation was rejected because the system is not in a state required for the operation's processing. * * @remarks * INVALID_ARGUMENT: The request is not valid. */ status?: components.Status | undefined; }; /** @internal */ export const BookingCreateTradeRequest$inboundSchema: z.ZodType< BookingCreateTradeRequest, z.ZodTypeDef, unknown > = z.object({ account_id: z.string(), TradeCreate: components.TradeCreate$inboundSchema, }).transform((v) => { return remap$(v, { "account_id": "accountId", "TradeCreate": "tradeCreate", }); }); /** @internal */ export type BookingCreateTradeRequest$Outbound = { account_id: string; TradeCreate: components.TradeCreate$Outbound; }; /** @internal */ export const BookingCreateTradeRequest$outboundSchema: z.ZodType< BookingCreateTradeRequest$Outbound, z.ZodTypeDef, BookingCreateTradeRequest > = z.object({ accountId: z.string(), tradeCreate: components.TradeCreate$outboundSchema, }).transform((v) => { return remap$(v, { accountId: "account_id", tradeCreate: "TradeCreate", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BookingCreateTradeRequest$ { /** @deprecated use `BookingCreateTradeRequest$inboundSchema` instead. */ export const inboundSchema = BookingCreateTradeRequest$inboundSchema; /** @deprecated use `BookingCreateTradeRequest$outboundSchema` instead. */ export const outboundSchema = BookingCreateTradeRequest$outboundSchema; /** @deprecated use `BookingCreateTradeRequest$Outbound` instead. */ export type Outbound = BookingCreateTradeRequest$Outbound; } export function bookingCreateTradeRequestToJSON( bookingCreateTradeRequest: BookingCreateTradeRequest, ): string { return JSON.stringify( BookingCreateTradeRequest$outboundSchema.parse(bookingCreateTradeRequest), ); } export function bookingCreateTradeRequestFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BookingCreateTradeRequest$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BookingCreateTradeRequest' from JSON`, ); } /** @internal */ export const BookingCreateTradeResponse$inboundSchema: z.ZodType< BookingCreateTradeResponse, z.ZodTypeDef, unknown > = z.object({ HttpMeta: components.HTTPMetadata$inboundSchema, BookingTrade: components.BookingTrade$inboundSchema.optional(), Status: components.Status$inboundSchema.optional(), }).transform((v) => { return remap$(v, { "HttpMeta": "httpMeta", "BookingTrade": "bookingTrade", "Status": "status", }); }); /** @internal */ export type BookingCreateTradeResponse$Outbound = { HttpMeta: components.HTTPMetadata$Outbound; BookingTrade?: components.BookingTrade$Outbound | undefined; Status?: components.Status$Outbound | undefined; }; /** @internal */ export const BookingCreateTradeResponse$outboundSchema: z.ZodType< BookingCreateTradeResponse$Outbound, z.ZodTypeDef, BookingCreateTradeResponse > = z.object({ httpMeta: components.HTTPMetadata$outboundSchema, bookingTrade: components.BookingTrade$outboundSchema.optional(), status: components.Status$outboundSchema.optional(), }).transform((v) => { return remap$(v, { httpMeta: "HttpMeta", bookingTrade: "BookingTrade", status: "Status", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace BookingCreateTradeResponse$ { /** @deprecated use `BookingCreateTradeResponse$inboundSchema` instead. */ export const inboundSchema = BookingCreateTradeResponse$inboundSchema; /** @deprecated use `BookingCreateTradeResponse$outboundSchema` instead. */ export const outboundSchema = BookingCreateTradeResponse$outboundSchema; /** @deprecated use `BookingCreateTradeResponse$Outbound` instead. */ export type Outbound = BookingCreateTradeResponse$Outbound; } export function bookingCreateTradeResponseToJSON( bookingCreateTradeResponse: BookingCreateTradeResponse, ): string { return JSON.stringify( BookingCreateTradeResponse$outboundSchema.parse(bookingCreateTradeResponse), ); } export function bookingCreateTradeResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => BookingCreateTradeResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'BookingCreateTradeResponse' from JSON`, ); }