/* * 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 { AlertSettings, AlertSettings$Outbound, AlertSettings$outboundSchema, } from "./alert-settings.js"; import { AutoTopup, AutoTopup$Outbound, AutoTopup$outboundSchema, } from "./auto-topup.js"; import { WalletType, WalletType$outboundSchema } from "./wallet-type.js"; export type CreateWalletRequest = { alertSettings?: AlertSettings | undefined; autoTopup?: AutoTopup | undefined; /** * amount in the currency = number of credits * conversion_rate * * @remarks * ex if conversion_rate is 1, then 1 USD = 1 credit * ex if conversion_rate is 2, then 1 USD = 0.5 credits * ex if conversion_rate is 0.5, then 1 USD = 2 credits */ conversionRate?: string | undefined; currency: string; customerId?: string | undefined; description?: string | undefined; /** * external_customer_id is the customer id in the external system */ externalCustomerId?: string | undefined; /** * initial_credits_expiry_date_utc is the expiry date in UTC timezone (optional to set nil means no expiry) * * @remarks * ex 2025-01-01 00:00:00 UTC */ initialCreditsExpiryDateUtc?: string | undefined; /** * initial_credits_to_load is the number of credits to load to the wallet * * @remarks * if not provided, the wallet will be created with 0 balance * NOTE: this is not the amount in the currency, but the number of credits */ initialCreditsToLoad?: string | undefined; /** * initial_credits_to_load_expiry_date YYYYMMDD format in UTC timezone (optional to set nil means no expiry) * * @remarks * for ex 20250101 means the credits will expire on 2025-01-01 00:00:00 UTC * hence they will be available for use until 2024-12-31 23:59:59 UTC */ initialCreditsToLoadExpiryDate?: number | undefined; metadata?: { [k: string]: string } | undefined; /** * price_unit is the code of the price unit to use for wallet creation * * @remarks * If provided, the price unit will be used to set the currency and conversion rate of the wallet: * - currency: set to price unit's base_currency * - conversion_rate: set to price unit's conversion_rate */ priceUnit?: string | undefined; /** * topup_conversion_rate is the conversion rate for the topup to the currency * * @remarks * ex if topup_conversion_rate is 1, then 1 USD = 1 credit * ex if topup_conversion_rate is 2, then 1 USD = 0.5 credits * ex if topup_conversion_rate is 0.5, then 1 USD = 2 credits */ topupConversionRate?: string | undefined; walletType?: WalletType | undefined; }; /** @internal */ export type CreateWalletRequest$Outbound = { alert_settings?: AlertSettings$Outbound | undefined; auto_topup?: AutoTopup$Outbound | undefined; conversion_rate: string; currency: string; customer_id?: string | undefined; description?: string | undefined; external_customer_id?: string | undefined; initial_credits_expiry_date_utc?: string | undefined; initial_credits_to_load: string; initial_credits_to_load_expiry_date?: number | undefined; metadata?: { [k: string]: string } | undefined; price_unit?: string | undefined; topup_conversion_rate?: string | undefined; wallet_type?: string | undefined; }; /** @internal */ export const CreateWalletRequest$outboundSchema: z.ZodMiniType< CreateWalletRequest$Outbound, CreateWalletRequest > = z.pipe( z.object({ alertSettings: z.optional(AlertSettings$outboundSchema), autoTopup: z.optional(AutoTopup$outboundSchema), conversionRate: z._default(z.string(), "1"), currency: z.string(), customerId: z.optional(z.string()), description: z.optional(z.string()), externalCustomerId: z.optional(z.string()), initialCreditsExpiryDateUtc: z.optional(z.string()), initialCreditsToLoad: z._default(z.string(), "0"), initialCreditsToLoadExpiryDate: z.optional(z.int()), metadata: z.optional(z.record(z.string(), z.string())), priceUnit: z.optional(z.string()), topupConversionRate: z.optional(z.string()), walletType: z.optional(WalletType$outboundSchema), }), z.transform((v) => { return remap$(v, { alertSettings: "alert_settings", autoTopup: "auto_topup", conversionRate: "conversion_rate", customerId: "customer_id", externalCustomerId: "external_customer_id", initialCreditsExpiryDateUtc: "initial_credits_expiry_date_utc", initialCreditsToLoad: "initial_credits_to_load", initialCreditsToLoadExpiryDate: "initial_credits_to_load_expiry_date", priceUnit: "price_unit", topupConversionRate: "topup_conversion_rate", walletType: "wallet_type", }); }), ); export function createWalletRequestToJSON( createWalletRequest: CreateWalletRequest, ): string { return JSON.stringify( CreateWalletRequest$outboundSchema.parse(createWalletRequest), ); }