/* * 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 { BenefitDownloadablesCreateProperties, BenefitDownloadablesCreateProperties$Outbound, BenefitDownloadablesCreateProperties$outboundSchema, } from "./benefitdownloadablescreateproperties.js"; export type BenefitDownloadablesCreateMetadata = | string | number | number | boolean; export type BenefitDownloadablesCreate = { /** * 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: "downloadables"; /** * 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: BenefitDownloadablesCreateProperties; }; /** @internal */ export type BenefitDownloadablesCreateMetadata$Outbound = | string | number | number | boolean; /** @internal */ export const BenefitDownloadablesCreateMetadata$outboundSchema: z.ZodMiniType< BenefitDownloadablesCreateMetadata$Outbound, BenefitDownloadablesCreateMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function benefitDownloadablesCreateMetadataToJSON( benefitDownloadablesCreateMetadata: BenefitDownloadablesCreateMetadata, ): string { return JSON.stringify( BenefitDownloadablesCreateMetadata$outboundSchema.parse( benefitDownloadablesCreateMetadata, ), ); } /** @internal */ export type BenefitDownloadablesCreate$Outbound = { metadata?: { [k: string]: string | number | number | boolean } | undefined; type: "downloadables"; description: string; organization_id?: string | null | undefined; properties: BenefitDownloadablesCreateProperties$Outbound; }; /** @internal */ export const BenefitDownloadablesCreate$outboundSchema: z.ZodMiniType< BenefitDownloadablesCreate$Outbound, BenefitDownloadablesCreate > = z.pipe( z.object({ metadata: z.optional( z.record( z.string(), smartUnion([z.string(), z.int(), z.number(), z.boolean()]), ), ), type: z.literal("downloadables"), description: z.string(), organizationId: z.optional(z.nullable(z.string())), properties: BenefitDownloadablesCreateProperties$outboundSchema, }), z.transform((v) => { return remap$(v, { organizationId: "organization_id", }); }), ); export function benefitDownloadablesCreateToJSON( benefitDownloadablesCreate: BenefitDownloadablesCreate, ): string { return JSON.stringify( BenefitDownloadablesCreate$outboundSchema.parse(benefitDownloadablesCreate), ); }