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

import * as z from "zod/v4-mini";
import { smartUnion } from "../../types/smartUnion.js";
import {
  BenefitLicenseKeysCreateProperties,
  BenefitLicenseKeysCreateProperties$Outbound,
  BenefitLicenseKeysCreateProperties$outboundSchema,
} from "./benefitlicensekeyscreateproperties.js";
import {
  BenefitVisibility,
  BenefitVisibility$outboundSchema,
} from "./benefitvisibility.js";

export type BenefitLicenseKeysUpdateMetadata =
  | string
  | number
  | number
  | boolean;

export type BenefitLicenseKeysUpdate = {
  /**
   * Key-value object allowing you to store additional information.
   *
   * @remarks
   *
   * The key must be a string with a maximum length of **40 characters**.
   * The value must be either:
   *
   * * A string with a maximum length of **500 characters**
   * * An integer
   * * A floating-point number
   * * A boolean
   *
   * You can store up to **50 key-value pairs**.
   */
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  /**
   * The description of the benefit. Will be displayed on products having this benefit.
   */
  description?: string | null | undefined;
  /**
   * The visibility of the benefit in the customer portal.
   */
  visibility?: BenefitVisibility | null | undefined;
  type: "license_keys";
  properties?: BenefitLicenseKeysCreateProperties | null | undefined;
};

/** @internal */
export type BenefitLicenseKeysUpdateMetadata$Outbound =
  | string
  | number
  | number
  | boolean;

/** @internal */
export const BenefitLicenseKeysUpdateMetadata$outboundSchema: z.ZodMiniType<
  BenefitLicenseKeysUpdateMetadata$Outbound,
  BenefitLicenseKeysUpdateMetadata
> = smartUnion([z.string(), z.int(), z.number(), z.boolean()]);

export function benefitLicenseKeysUpdateMetadataToJSON(
  benefitLicenseKeysUpdateMetadata: BenefitLicenseKeysUpdateMetadata,
): string {
  return JSON.stringify(
    BenefitLicenseKeysUpdateMetadata$outboundSchema.parse(
      benefitLicenseKeysUpdateMetadata,
    ),
  );
}

/** @internal */
export type BenefitLicenseKeysUpdate$Outbound = {
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  description?: string | null | undefined;
  visibility?: string | null | undefined;
  type: "license_keys";
  properties?: BenefitLicenseKeysCreateProperties$Outbound | null | undefined;
};

/** @internal */
export const BenefitLicenseKeysUpdate$outboundSchema: z.ZodMiniType<
  BenefitLicenseKeysUpdate$Outbound,
  BenefitLicenseKeysUpdate
> = z.object({
  metadata: z.optional(
    z.record(
      z.string(),
      smartUnion([z.string(), z.int(), z.number(), z.boolean()]),
    ),
  ),
  description: z.optional(z.nullable(z.string())),
  visibility: z.optional(z.nullable(BenefitVisibility$outboundSchema)),
  type: z.literal("license_keys"),
  properties: z.optional(
    z.nullable(BenefitLicenseKeysCreateProperties$outboundSchema),
  ),
});

export function benefitLicenseKeysUpdateToJSON(
  benefitLicenseKeysUpdate: BenefitLicenseKeysUpdate,
): string {
  return JSON.stringify(
    BenefitLicenseKeysUpdate$outboundSchema.parse(benefitLicenseKeysUpdate),
  );
}
