/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; /** * The net amount of the trade in USD. This value is always positive. */ export type NetAmount = { /** * 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; }; /** * A summary of a trade. */ export type CalculateCashBalanceResponseTradeSummary = { /** * The ledger activity for the trade. */ activity?: string | undefined; /** * The asset that was traded. */ asset?: string | undefined; /** * The net amount of the trade in USD. This value is always positive. */ netAmount?: NetAmount | null | undefined; }; /** @internal */ export const NetAmount$inboundSchema: z.ZodType< NetAmount, z.ZodTypeDef, unknown > = z.object({ value: z.string().optional(), }); /** @internal */ export type NetAmount$Outbound = { value?: string | undefined; }; /** @internal */ export const NetAmount$outboundSchema: z.ZodType< NetAmount$Outbound, z.ZodTypeDef, NetAmount > = 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 NetAmount$ { /** @deprecated use `NetAmount$inboundSchema` instead. */ export const inboundSchema = NetAmount$inboundSchema; /** @deprecated use `NetAmount$outboundSchema` instead. */ export const outboundSchema = NetAmount$outboundSchema; /** @deprecated use `NetAmount$Outbound` instead. */ export type Outbound = NetAmount$Outbound; } export function netAmountToJSON(netAmount: NetAmount): string { return JSON.stringify(NetAmount$outboundSchema.parse(netAmount)); } export function netAmountFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => NetAmount$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'NetAmount' from JSON`, ); } /** @internal */ export const CalculateCashBalanceResponseTradeSummary$inboundSchema: z.ZodType< CalculateCashBalanceResponseTradeSummary, z.ZodTypeDef, unknown > = z.object({ activity: z.string().optional(), asset: z.string().optional(), net_amount: z.nullable(z.lazy(() => NetAmount$inboundSchema)).optional(), }).transform((v) => { return remap$(v, { "net_amount": "netAmount", }); }); /** @internal */ export type CalculateCashBalanceResponseTradeSummary$Outbound = { activity?: string | undefined; asset?: string | undefined; net_amount?: NetAmount$Outbound | null | undefined; }; /** @internal */ export const CalculateCashBalanceResponseTradeSummary$outboundSchema: z.ZodType< CalculateCashBalanceResponseTradeSummary$Outbound, z.ZodTypeDef, CalculateCashBalanceResponseTradeSummary > = z.object({ activity: z.string().optional(), asset: z.string().optional(), netAmount: z.nullable(z.lazy(() => NetAmount$outboundSchema)).optional(), }).transform((v) => { return remap$(v, { netAmount: "net_amount", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace CalculateCashBalanceResponseTradeSummary$ { /** @deprecated use `CalculateCashBalanceResponseTradeSummary$inboundSchema` instead. */ export const inboundSchema = CalculateCashBalanceResponseTradeSummary$inboundSchema; /** @deprecated use `CalculateCashBalanceResponseTradeSummary$outboundSchema` instead. */ export const outboundSchema = CalculateCashBalanceResponseTradeSummary$outboundSchema; /** @deprecated use `CalculateCashBalanceResponseTradeSummary$Outbound` instead. */ export type Outbound = CalculateCashBalanceResponseTradeSummary$Outbound; } export function calculateCashBalanceResponseTradeSummaryToJSON( calculateCashBalanceResponseTradeSummary: CalculateCashBalanceResponseTradeSummary, ): string { return JSON.stringify( CalculateCashBalanceResponseTradeSummary$outboundSchema.parse( calculateCashBalanceResponseTradeSummary, ), ); } export function calculateCashBalanceResponseTradeSummaryFromJSON( jsonString: string, ): SafeParseResult< CalculateCashBalanceResponseTradeSummary, SDKValidationError > { return safeParse( jsonString, (x) => CalculateCashBalanceResponseTradeSummary$inboundSchema.parse( JSON.parse(x), ), `Failed to parse 'CalculateCashBalanceResponseTradeSummary' from JSON`, ); }