/* * 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"; import { BenefitDiscordCreateProperties, BenefitDiscordCreateProperties$Outbound, BenefitDiscordCreateProperties$outboundSchema, } from "./benefitdiscordcreateproperties.js"; export type BenefitDiscordCreateMetadata = string | number | number | boolean; export type BenefitDiscordCreate = { /** * 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; type: "discord"; /** * The description of the benefit. Will be displayed on products having this benefit. */ description: string; /** * The ID of the organization owning the benefit. **Required unless you use an organization token.** */ organizationId?: string | null | undefined; /** * Properties to create a benefit of type `discord`. */ properties: BenefitDiscordCreateProperties; }; /** @internal */ export type BenefitDiscordCreateMetadata$Outbound = | string | number | number | boolean; /** @internal */ export const BenefitDiscordCreateMetadata$outboundSchema: z.ZodMiniType< BenefitDiscordCreateMetadata$Outbound, BenefitDiscordCreateMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function benefitDiscordCreateMetadataToJSON( benefitDiscordCreateMetadata: BenefitDiscordCreateMetadata, ): string { return JSON.stringify( BenefitDiscordCreateMetadata$outboundSchema.parse( benefitDiscordCreateMetadata, ), ); } /** @internal */ export type BenefitDiscordCreate$Outbound = { metadata?: { [k: string]: string | number | number | boolean } | undefined; type: "discord"; description: string; organization_id?: string | null | undefined; properties: BenefitDiscordCreateProperties$Outbound; }; /** @internal */ export const BenefitDiscordCreate$outboundSchema: z.ZodMiniType< BenefitDiscordCreate$Outbound, BenefitDiscordCreate > = z.pipe( z.object({ metadata: z.optional( z.record( z.string(), smartUnion([z.string(), z.int(), z.number(), z.boolean()]), ), ), type: z.literal("discord"), description: z.string(), organizationId: z.optional(z.nullable(z.string())), properties: BenefitDiscordCreateProperties$outboundSchema, }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", }); }), ); export function benefitDiscordCreateToJSON( benefitDiscordCreate: BenefitDiscordCreate, ): string { return JSON.stringify( BenefitDiscordCreate$outboundSchema.parse(benefitDiscordCreate), ); }