/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import {
  UpdateKeyCreditsRefill,
  UpdateKeyCreditsRefill$Outbound,
  UpdateKeyCreditsRefill$outboundSchema,
} from "./updatekeycreditsrefill.js";

/**
 * Credit configuration and remaining balance for this key.
 */
export type UpdateKeyCreditsData = {
  /**
   * Number of credits remaining (null for unlimited). This also clears the refilling schedule.
   */
  remaining?: number | null | undefined;
  /**
   * Configuration for automatic credit refill behavior.
   */
  refill?: UpdateKeyCreditsRefill | null | undefined;
};

/** @internal */
export type UpdateKeyCreditsData$Outbound = {
  remaining?: number | null | undefined;
  refill?: UpdateKeyCreditsRefill$Outbound | null | undefined;
};

/** @internal */
export const UpdateKeyCreditsData$outboundSchema: z.ZodType<
  UpdateKeyCreditsData$Outbound,
  z.ZodTypeDef,
  UpdateKeyCreditsData
> = z.object({
  remaining: z.nullable(z.number().int()).optional(),
  refill: z.nullable(UpdateKeyCreditsRefill$outboundSchema).optional(),
});

export function updateKeyCreditsDataToJSON(
  updateKeyCreditsData: UpdateKeyCreditsData,
): string {
  return JSON.stringify(
    UpdateKeyCreditsData$outboundSchema.parse(updateKeyCreditsData),
  );
}
