/*
* 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 {
AccountIdentifier,
AccountIdentifier$inboundSchema,
AccountIdentifier$Outbound,
AccountIdentifier$outboundSchema,
} from "./accountidentifier.js";
import {
Currency,
Currency$inboundSchema,
Currency$Outbound,
Currency$outboundSchema,
} from "./currency.js";
import { SDKValidationError } from "./errors/sdkvalidationerror.js";
import {
NetworkIdentifier,
NetworkIdentifier$inboundSchema,
NetworkIdentifier$Outbound,
NetworkIdentifier$outboundSchema,
} from "./networkidentifier.js";
import {
PartialBlockIdentifier,
PartialBlockIdentifier$inboundSchema,
PartialBlockIdentifier$Outbound,
PartialBlockIdentifier$outboundSchema,
} from "./partialblockidentifier.js";
/**
* An AccountBalanceRequest is utilized to make a balance request on the /account/balance endpoint. If the block_identifier is populated, a historical balance query should be performed.
*/
export type AccountBalanceRequest = {
/**
* The network_identifier specifies which network a particular object is associated with.
*/
networkIdentifier: NetworkIdentifier;
/**
* The account_identifier uniquely identifies an account within a network. All fields in the account_identifier are utilized to determine this uniqueness (including the metadata field, if populated).
*/
accountIdentifier: AccountIdentifier;
/**
* When fetching data by BlockIdentifier, it may be possible to only specify the index or hash. If neither property is specified, it is assumed that the client is making a request at the current block.
*/
blockIdentifier?: PartialBlockIdentifier | undefined;
/**
* In some cases, the caller may not want to retrieve all available balances for an AccountIdentifier. If the currencies field is populated, only balances for the specified currencies will be returned. If not populated, all available balances will be returned.
*/
currencies?: Array<Currency> | undefined;
};
/** @internal */
export const AccountBalanceRequest$inboundSchema: z.ZodType<
AccountBalanceRequest,
z.ZodTypeDef,
unknown
> = z.object({
network_identifier: NetworkIdentifier$inboundSchema,
account_identifier: AccountIdentifier$inboundSchema,
block_identifier: PartialBlockIdentifier$inboundSchema.optional(),
currencies: z.array(Currency$inboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
"network_identifier": "networkIdentifier",
"account_identifier": "accountIdentifier",
"block_identifier": "blockIdentifier",
});
});
/** @internal */
export type AccountBalanceRequest$Outbound = {
network_identifier: NetworkIdentifier$Outbound;
account_identifier: AccountIdentifier$Outbound;
block_identifier?: PartialBlockIdentifier$Outbound | undefined;
currencies?: Array<Currency$Outbound> | undefined;
};
/** @internal */
export const AccountBalanceRequest$outboundSchema: z.ZodType<
AccountBalanceRequest$Outbound,
z.ZodTypeDef,
AccountBalanceRequest
> = z.object({
networkIdentifier: NetworkIdentifier$outboundSchema,
accountIdentifier: AccountIdentifier$outboundSchema,
blockIdentifier: PartialBlockIdentifier$outboundSchema.optional(),
currencies: z.array(Currency$outboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
networkIdentifier: "network_identifier",
accountIdentifier: "account_identifier",
blockIdentifier: "block_identifier",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace AccountBalanceRequest$ {
/** @deprecated use `AccountBalanceRequest$inboundSchema` instead. */
export const inboundSchema = AccountBalanceRequest$inboundSchema;
/** @deprecated use `AccountBalanceRequest$outboundSchema` instead. */
export const outboundSchema = AccountBalanceRequest$outboundSchema;
/** @deprecated use `AccountBalanceRequest$Outbound` instead. */
export type Outbound = AccountBalanceRequest$Outbound;
}
export function accountBalanceRequestToJSON(
accountBalanceRequest: AccountBalanceRequest,
): string {
return JSON.stringify(
AccountBalanceRequest$outboundSchema.parse(accountBalanceRequest),
);
}
export function accountBalanceRequestFromJSON(
jsonString: string,
): SafeParseResult<AccountBalanceRequest, SDKValidationError> {
return safeParse(
jsonString,
(x) => AccountBalanceRequest$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'AccountBalanceRequest' from JSON`,
);
}