/* * 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 { SDKValidationError } from "../errors/sdkvalidationerror.js"; import { LicenseKeyActivationBase, LicenseKeyActivationBase$inboundSchema, } from "./licensekeyactivationbase.js"; import { LicenseKeyCustomer, LicenseKeyCustomer$inboundSchema, } from "./licensekeycustomer.js"; import { LicenseKeyStatus, LicenseKeyStatus$inboundSchema, } from "./licensekeystatus.js"; export type ValidatedLicenseKey = { /** * The ID of the object. */ id: string; /** * Creation timestamp of the object. */ createdAt: Date; /** * Last modification timestamp of the object. */ modifiedAt: Date | null; organizationId: string; customerId: string; customer: LicenseKeyCustomer; /** * The benefit ID. */ benefitId: string; key: string; displayKey: string; status: LicenseKeyStatus; limitActivations: number | null; usage: number; limitUsage: number | null; validations: number; lastValidatedAt: Date | null; expiresAt: Date | null; activation?: LicenseKeyActivationBase | null | undefined; }; /** @internal */ export const ValidatedLicenseKey$inboundSchema: z.ZodMiniType< ValidatedLicenseKey, unknown > = z.pipe( z.object({ id: z.string(), created_at: z.pipe( z.iso.datetime({ offset: true }), z.transform(v => new Date(v)), ), modified_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), organization_id: z.string(), customer_id: z.string(), customer: LicenseKeyCustomer$inboundSchema, benefit_id: z.string(), key: z.string(), display_key: z.string(), status: LicenseKeyStatus$inboundSchema, limit_activations: z.nullable(z.int()), usage: z.int(), limit_usage: z.nullable(z.int()), validations: z.int(), last_validated_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), expires_at: z.nullable( z.pipe(z.iso.datetime({ offset: true }), z.transform(v => new Date(v))), ), activation: z.optional(z.nullable(LicenseKeyActivationBase$inboundSchema)), }), z.transform((v) => { return remap$(v, { "created_at": "createdAt", "modified_at": "modifiedAt", "organization_id": "organizationId", "customer_id": "customerId", "benefit_id": "benefitId", "display_key": "displayKey", "limit_activations": "limitActivations", "limit_usage": "limitUsage", "last_validated_at": "lastValidatedAt", "expires_at": "expiresAt", }); }), ); export function validatedLicenseKeyFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => ValidatedLicenseKey$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'ValidatedLicenseKey' from JSON`, ); }