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

import * as z from "zod/v4-mini";
import { smartUnion } from "../../types/smartUnion.js";
import {
  BenefitDiscordCreateProperties,
  BenefitDiscordCreateProperties$Outbound,
  BenefitDiscordCreateProperties$outboundSchema,
} from "./benefitdiscordcreateproperties.js";

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

export type BenefitDiscordUpdate = {
  /**
   * 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;
  type: "discord";
  properties?: BenefitDiscordCreateProperties | null | undefined;
};

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

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

export function benefitDiscordUpdateMetadataToJSON(
  benefitDiscordUpdateMetadata: BenefitDiscordUpdateMetadata,
): string {
  return JSON.stringify(
    BenefitDiscordUpdateMetadata$outboundSchema.parse(
      benefitDiscordUpdateMetadata,
    ),
  );
}

/** @internal */
export type BenefitDiscordUpdate$Outbound = {
  metadata?: { [k: string]: string | number | number | boolean } | undefined;
  description?: string | null | undefined;
  type: "discord";
  properties?: BenefitDiscordCreateProperties$Outbound | null | undefined;
};

/** @internal */
export const BenefitDiscordUpdate$outboundSchema: z.ZodMiniType<
  BenefitDiscordUpdate$Outbound,
  BenefitDiscordUpdate
> = 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())),
  type: z.literal("discord"),
  properties: z.optional(
    z.nullable(BenefitDiscordCreateProperties$outboundSchema),
  ),
});

export function benefitDiscordUpdateToJSON(
  benefitDiscordUpdate: BenefitDiscordUpdate,
): string {
  return JSON.stringify(
    BenefitDiscordUpdate$outboundSchema.parse(benefitDiscordUpdate),
  );
}
