@unkey/api
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@unkey/api* API.
77 lines (69 loc) • 1.94 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import * as openEnums from "../../types/enums.js";
import { OpenEnum } from "../../types/enums.js";
/**
* How often credits are automatically refilled.
*/
export const UpdateKeyCreditsRefillInterval = {
Daily: "daily",
Monthly: "monthly",
} as const;
/**
* How often credits are automatically refilled.
*/
export type UpdateKeyCreditsRefillInterval = OpenEnum<
typeof UpdateKeyCreditsRefillInterval
>;
/**
* Configuration for automatic credit refill behavior.
*/
export type UpdateKeyCreditsRefill = {
/**
* How often credits are automatically refilled.
*/
interval: UpdateKeyCreditsRefillInterval;
/**
* Number of credits to add during each refill cycle.
*/
amount: number;
/**
* Day of the month for monthly refills (1-31).
*
* @remarks
* Only required when interval is 'monthly'.
* For days beyond the month's length, refill occurs on the last day of the month.
*/
refillDay?: number | undefined;
};
/** @internal */
export const UpdateKeyCreditsRefillInterval$outboundSchema: z.ZodType<
string,
z.ZodTypeDef,
UpdateKeyCreditsRefillInterval
> = openEnums.outboundSchema(UpdateKeyCreditsRefillInterval);
/** @internal */
export type UpdateKeyCreditsRefill$Outbound = {
interval: string;
amount: number;
refillDay?: number | undefined;
};
/** @internal */
export const UpdateKeyCreditsRefill$outboundSchema: z.ZodType<
UpdateKeyCreditsRefill$Outbound,
z.ZodTypeDef,
UpdateKeyCreditsRefill
> = z.object({
interval: UpdateKeyCreditsRefillInterval$outboundSchema,
amount: z.number().int(),
refillDay: z.number().int().optional(),
});
export function updateKeyCreditsRefillToJSON(
updateKeyCreditsRefill: UpdateKeyCreditsRefill,
): string {
return JSON.stringify(
UpdateKeyCreditsRefill$outboundSchema.parse(updateKeyCreditsRefill),
);
}