/* * 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 { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import * as types from "../../types/primitives.js"; import { CouponCadence, CouponCadence$inboundSchema, } from "./coupon-cadence.js"; import { CouponType, CouponType$inboundSchema } from "./coupon-type.js"; import { SDKValidationError } from "./sdk-validation-error.js"; import { Status, Status$inboundSchema } from "./status.js"; export type CouponResponse = { amountOff?: string | undefined; cadence?: CouponCadence | undefined; couponCode?: string | undefined; createdAt?: Date | undefined; createdBy?: string | undefined; currency?: string | undefined; durationInPeriods?: number | undefined; environmentId?: string | undefined; id?: string | undefined; maxRedemptions?: number | undefined; metadata?: { [k: string]: string } | undefined; name?: string | undefined; percentageOff?: string | undefined; redeemAfter?: string | undefined; redeemBefore?: string | undefined; rules?: { [k: string]: any } | undefined; status?: Status | undefined; tenantId?: string | undefined; totalRedemptions?: number | undefined; type?: CouponType | undefined; updatedAt?: Date | undefined; updatedBy?: string | undefined; }; /** @internal */ export const CouponResponse$inboundSchema: z.ZodMiniType< CouponResponse, unknown > = z.pipe( z.object({ amount_off: types.optional(types.string()), cadence: types.optional(CouponCadence$inboundSchema), coupon_code: types.optional(types.string()), created_at: types.optional(types.date()), created_by: types.optional(types.string()), currency: types.optional(types.string()), duration_in_periods: types.optional(types.number()), environment_id: types.optional(types.string()), id: types.optional(types.string()), max_redemptions: types.optional(types.number()), metadata: types.optional(z.record(z.string(), types.string())), name: types.optional(types.string()), percentage_off: types.optional(types.string()), redeem_after: types.optional(types.string()), redeem_before: types.optional(types.string()), rules: types.optional(z.record(z.string(), z.any())), status: types.optional(Status$inboundSchema), tenant_id: types.optional(types.string()), total_redemptions: types.optional(types.number()), type: types.optional(CouponType$inboundSchema), updated_at: types.optional(types.date()), updated_by: types.optional(types.string()), }), z.transform((v) => { return remap$(v, { "amount_off": "amountOff", "coupon_code": "couponCode", "created_at": "createdAt", "created_by": "createdBy", "duration_in_periods": "durationInPeriods", "environment_id": "environmentId", "max_redemptions": "maxRedemptions", "percentage_off": "percentageOff", "redeem_after": "redeemAfter", "redeem_before": "redeemBefore", "tenant_id": "tenantId", "total_redemptions": "totalRedemptions", "updated_at": "updatedAt", "updated_by": "updatedBy", }); }), ); export function couponResponseFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => CouponResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CouponResponse' from JSON`, ); }