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

import * as z from "zod/v4-mini";
import { remap as remap$ } from "../../lib/primitives.js";
import { smartUnion } from "../../types/smartUnion.js";

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

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

export type LicenseKeyActivate = {
  key: string;
  organizationId: string;
  label: string;
  /**
   * Key-value object allowing you to set conditions that must match when validating the license key.
   *
   * @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**.
   */
  conditions?: { [k: string]: string | number | number | boolean } | undefined;
  /**
   * Key-value object allowing you to store additional information about the activation
   *
   * @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**.
   */
  meta?: { [k: string]: string | number | number | boolean } | undefined;
};

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

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

export function licenseKeyActivateConditionsToJSON(
  licenseKeyActivateConditions: LicenseKeyActivateConditions,
): string {
  return JSON.stringify(
    LicenseKeyActivateConditions$outboundSchema.parse(
      licenseKeyActivateConditions,
    ),
  );
}

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

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

export function licenseKeyActivateMetaToJSON(
  licenseKeyActivateMeta: LicenseKeyActivateMeta,
): string {
  return JSON.stringify(
    LicenseKeyActivateMeta$outboundSchema.parse(licenseKeyActivateMeta),
  );
}

/** @internal */
export type LicenseKeyActivate$Outbound = {
  key: string;
  organization_id: string;
  label: string;
  conditions?: { [k: string]: string | number | number | boolean } | undefined;
  meta?: { [k: string]: string | number | number | boolean } | undefined;
};

/** @internal */
export const LicenseKeyActivate$outboundSchema: z.ZodMiniType<
  LicenseKeyActivate$Outbound,
  LicenseKeyActivate
> = z.pipe(
  z.object({
    key: z.string(),
    organizationId: z.string(),
    label: z.string(),
    conditions: z.optional(
      z.record(
        z.string(),
        smartUnion([z.string(), z.int(), z.number(), z.boolean()]),
      ),
    ),
    meta: z.optional(
      z.record(
        z.string(),
        smartUnion([z.string(), z.int(), z.number(), z.boolean()]),
      ),
    ),
  }),
  z.transform((v) => {
    return remap$(v, {
      organizationId: "organization_id",
    });
  }),
);

export function licenseKeyActivateToJSON(
  licenseKeyActivate: LicenseKeyActivate,
): string {
  return JSON.stringify(
    LicenseKeyActivate$outboundSchema.parse(licenseKeyActivate),
  );
}
