/* * 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 SubscriptionCreateExternalCustomerMetadata = | string | number | number | boolean; /** * Create a subscription for an existing customer identified by an external ID. */ export type SubscriptionCreateExternalCustomer = { /** * 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 ID of the recurring product to subscribe to. Must be a free product, otherwise the customer should go through a checkout flow. */ productId: string; /** * The ID of the customer in your system to create the subscription for. It must already exist in Polar. */ externalCustomerId: string; }; /** @internal */ export type SubscriptionCreateExternalCustomerMetadata$Outbound = | string | number | number | boolean; /** @internal */ export const SubscriptionCreateExternalCustomerMetadata$outboundSchema: z.ZodMiniType< SubscriptionCreateExternalCustomerMetadata$Outbound, SubscriptionCreateExternalCustomerMetadata > = smartUnion([z.string(), z.int(), z.number(), z.boolean()]); export function subscriptionCreateExternalCustomerMetadataToJSON( subscriptionCreateExternalCustomerMetadata: SubscriptionCreateExternalCustomerMetadata, ): string { return JSON.stringify( SubscriptionCreateExternalCustomerMetadata$outboundSchema.parse( subscriptionCreateExternalCustomerMetadata, ), ); } /** @internal */ export type SubscriptionCreateExternalCustomer$Outbound = { metadata?: { [k: string]: string | number | number | boolean } | undefined; product_id: string; external_customer_id: string; }; /** @internal */ export const SubscriptionCreateExternalCustomer$outboundSchema: z.ZodMiniType< SubscriptionCreateExternalCustomer$Outbound, SubscriptionCreateExternalCustomer > = z.pipe( z.object({ metadata: z.optional( z.record( z.string(), smartUnion([z.string(), z.int(), z.number(), z.boolean()]), ), ), productId: z.string(), externalCustomerId: z.string(), }), z.transform((v) => { return remap$(v, { productId: "product_id", externalCustomerId: "external_customer_id", }); }), ); export function subscriptionCreateExternalCustomerToJSON( subscriptionCreateExternalCustomer: SubscriptionCreateExternalCustomer, ): string { return JSON.stringify( SubscriptionCreateExternalCustomer$outboundSchema.parse( subscriptionCreateExternalCustomer, ), ); }