@vercel/sdk
Version:
<p align="center"> <a href="https://vercel.com"> <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96"> <h3 align="center">Vercel</h3> </a> <p align="center">Develop. Preview. Ship.</p> </p>
123 lines (109 loc) • 3.52 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { remap as remap$ } from "../lib/primitives.js";
/**
* A credit balance for a particular token type
*/
export type Balances = {
/**
* Partner's resource ID, exclude if credits are tied to the installation and not an individual resource.
*/
resourceId?: string | undefined;
/**
* A human-readable description of the credits the user currently has, e.g. "2,000 Tokens"
*/
credit?: string | undefined;
/**
* The name of the credits, for display purposes, e.g. "Tokens"
*/
nameLabel?: string | undefined;
/**
* The dollar value of the credit balance, in USD and provided in cents, which is used to trigger automatic purchase thresholds.
*/
currencyValueInCents: number;
};
export type SubmitPrepaymentBalancesRequestBody = {
/**
* Server time of your integration, used to determine the most recent data for race conditions & updates. Only the latest usage data for a given day, week, and month will be kept.
*/
timestamp: Date;
balances: Array<Balances>;
};
export type SubmitPrepaymentBalancesRequest = {
integrationConfigurationId: string;
requestBody?: SubmitPrepaymentBalancesRequestBody | undefined;
};
/** @internal */
export type Balances$Outbound = {
resourceId?: string | undefined;
credit?: string | undefined;
nameLabel?: string | undefined;
currencyValueInCents: number;
};
/** @internal */
export const Balances$outboundSchema: z.ZodType<
Balances$Outbound,
z.ZodTypeDef,
Balances
> = z.object({
resourceId: z.string().optional(),
credit: z.string().optional(),
nameLabel: z.string().optional(),
currencyValueInCents: z.number(),
});
export function balancesToJSON(balances: Balances): string {
return JSON.stringify(Balances$outboundSchema.parse(balances));
}
/** @internal */
export type SubmitPrepaymentBalancesRequestBody$Outbound = {
timestamp: string;
balances: Array<Balances$Outbound>;
};
/** @internal */
export const SubmitPrepaymentBalancesRequestBody$outboundSchema: z.ZodType<
SubmitPrepaymentBalancesRequestBody$Outbound,
z.ZodTypeDef,
SubmitPrepaymentBalancesRequestBody
> = z.object({
timestamp: z.date().transform(v => v.toISOString()),
balances: z.array(z.lazy(() => Balances$outboundSchema)),
});
export function submitPrepaymentBalancesRequestBodyToJSON(
submitPrepaymentBalancesRequestBody: SubmitPrepaymentBalancesRequestBody,
): string {
return JSON.stringify(
SubmitPrepaymentBalancesRequestBody$outboundSchema.parse(
submitPrepaymentBalancesRequestBody,
),
);
}
/** @internal */
export type SubmitPrepaymentBalancesRequest$Outbound = {
integrationConfigurationId: string;
RequestBody?: SubmitPrepaymentBalancesRequestBody$Outbound | undefined;
};
/** @internal */
export const SubmitPrepaymentBalancesRequest$outboundSchema: z.ZodType<
SubmitPrepaymentBalancesRequest$Outbound,
z.ZodTypeDef,
SubmitPrepaymentBalancesRequest
> = z.object({
integrationConfigurationId: z.string(),
requestBody: z.lazy(() => SubmitPrepaymentBalancesRequestBody$outboundSchema)
.optional(),
}).transform((v) => {
return remap$(v, {
requestBody: "RequestBody",
});
});
export function submitPrepaymentBalancesRequestToJSON(
submitPrepaymentBalancesRequest: SubmitPrepaymentBalancesRequest,
): string {
return JSON.stringify(
SubmitPrepaymentBalancesRequest$outboundSchema.parse(
submitPrepaymentBalancesRequest,
),
);
}